blob: 3ecb6ddd00c6bbeeeac40050435e4e72382809b7 [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 Huberf361ec82018-06-02 18:01:45 +020054 procedure Scaler_Available (Available : out Boolean; Pipe : Pipe_Index);
55
Nico Huber83693c82016-10-08 22:17:55 +020056private
57
58 subtype WM_Levels is Natural range 0 .. 7;
59 type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
60
61 type Controller_Type is
62 record
Nico Huberf3e23662016-12-05 21:33:03 +010063 Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020064 PIPESRC : Registers.Registers_Index;
65 PIPEMISC : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010066 PF_CTRL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020067 PF_WIN_POS : Registers.Registers_Index;
68 PF_WIN_SZ : Registers.Registers_Index;
69 DSPCNTR : Registers.Registers_Index;
70 DSPLINOFF : Registers.Registers_Index;
71 DSPSTRIDE : Registers.Registers_Index;
72 DSPSURF : Registers.Registers_Index;
73 DSPTILEOFF : Registers.Registers_Index;
74 SPCNTR : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020075 -- Skylake registers (partially aliased)
76 PLANE_CTL : Registers.Registers_Index;
77 PLANE_OFFSET : Registers.Registers_Index;
78 PLANE_POS : Registers.Registers_Index;
79 PLANE_SIZE : Registers.Registers_Index;
80 PLANE_STRIDE : Registers.Registers_Index;
81 PLANE_SURF : Registers.Registers_Index;
82 PS_CTRL_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010083 PS_WIN_POS_1 : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020084 PS_WIN_SZ_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010085 PS_CTRL_2 : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +020086 PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
87 WM_LINETIME : Registers.Registers_Index;
88 PLANE_BUF_CFG : Registers.Registers_Index;
89 PLANE_WM : PLANE_WM_Type;
Nico Huber4dc4c612018-01-10 15:55:09 +010090 CUR_BUF_CFG : Registers.Registers_Index;
91 CUR_WM : PLANE_WM_Type;
Nico Huber83693c82016-10-08 22:17:55 +020092 end record;
93
Nico Huberf3e23662016-12-05 21:33:03 +010094 type Controller_Array is array (Pipe_Index) of Controller_Type;
95
Nico Huberf3e23662016-12-05 21:33:03 +010096 Controllers : constant Controller_Array :=
97 (Primary => Controller_Type'
98 (Pipe => Primary,
Nico Huber83693c82016-10-08 22:17:55 +020099 PIPESRC => Registers.PIPEASRC,
100 PIPEMISC => Registers.PIPEAMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100101 PF_CTRL => Registers.PFA_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200102 PF_WIN_POS => Registers.PFA_WIN_POS,
103 PF_WIN_SZ => Registers.PFA_WIN_SZ,
104 DSPCNTR => Registers.DSPACNTR,
105 DSPLINOFF => Registers.DSPALINOFF,
106 DSPSTRIDE => Registers.DSPASTRIDE,
107 DSPSURF => Registers.DSPASURF,
108 DSPTILEOFF => Registers.DSPATILEOFF,
109 SPCNTR => Registers.SPACNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200110 PLANE_CTL => Registers.DSPACNTR,
111 PLANE_OFFSET => Registers.DSPATILEOFF,
112 PLANE_POS => Registers.PLANE_POS_1_A,
113 PLANE_SIZE => Registers.PLANE_SIZE_1_A,
114 PLANE_STRIDE => Registers.DSPASTRIDE,
115 PLANE_SURF => Registers.DSPASURF,
116 PS_CTRL_1 => Registers.PS_CTRL_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100117 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_A,
Nico Huber83693c82016-10-08 22:17:55 +0200118 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100119 PS_CTRL_2 => Registers.PS_CTRL_2_A,
Nico Huber83693c82016-10-08 22:17:55 +0200120 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_A,
121 WM_LINETIME => Registers.WM_LINETIME_A,
122 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_A,
123 PLANE_WM => PLANE_WM_Type'(
124 Registers.PLANE_WM_1_A_0,
125 Registers.PLANE_WM_1_A_1,
126 Registers.PLANE_WM_1_A_2,
127 Registers.PLANE_WM_1_A_3,
128 Registers.PLANE_WM_1_A_4,
129 Registers.PLANE_WM_1_A_5,
130 Registers.PLANE_WM_1_A_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100131 Registers.PLANE_WM_1_A_7),
132 CUR_BUF_CFG => Registers.CUR_BUF_CFG_A,
133 CUR_WM => PLANE_WM_Type'(
134 Registers.CUR_WM_A_0,
135 Registers.CUR_WM_A_1,
136 Registers.CUR_WM_A_2,
137 Registers.CUR_WM_A_3,
138 Registers.CUR_WM_A_4,
139 Registers.CUR_WM_A_5,
140 Registers.CUR_WM_A_6,
141 Registers.CUR_WM_A_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100142 Secondary => Controller_Type'
143 (Pipe => Secondary,
Nico Huber83693c82016-10-08 22:17:55 +0200144 PIPESRC => Registers.PIPEBSRC,
145 PIPEMISC => Registers.PIPEBMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100146 PF_CTRL => Registers.PFB_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200147 PF_WIN_POS => Registers.PFB_WIN_POS,
148 PF_WIN_SZ => Registers.PFB_WIN_SZ,
149 DSPCNTR => Registers.DSPBCNTR,
150 DSPLINOFF => Registers.DSPBLINOFF,
151 DSPSTRIDE => Registers.DSPBSTRIDE,
152 DSPSURF => Registers.DSPBSURF,
153 DSPTILEOFF => Registers.DSPBTILEOFF,
154 SPCNTR => Registers.SPBCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200155 PLANE_CTL => Registers.DSPBCNTR,
156 PLANE_OFFSET => Registers.DSPBTILEOFF,
157 PLANE_POS => Registers.PLANE_POS_1_B,
158 PLANE_SIZE => Registers.PLANE_SIZE_1_B,
159 PLANE_STRIDE => Registers.DSPBSTRIDE,
160 PLANE_SURF => Registers.DSPBSURF,
161 PS_CTRL_1 => Registers.PS_CTRL_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100162 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
Nico Huber83693c82016-10-08 22:17:55 +0200163 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100164 PS_CTRL_2 => Registers.PS_CTRL_2_B,
Nico Huber83693c82016-10-08 22:17:55 +0200165 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B,
166 WM_LINETIME => Registers.WM_LINETIME_B,
167 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B,
168 PLANE_WM => PLANE_WM_Type'(
169 Registers.PLANE_WM_1_B_0,
170 Registers.PLANE_WM_1_B_1,
171 Registers.PLANE_WM_1_B_2,
172 Registers.PLANE_WM_1_B_3,
173 Registers.PLANE_WM_1_B_4,
174 Registers.PLANE_WM_1_B_5,
175 Registers.PLANE_WM_1_B_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100176 Registers.PLANE_WM_1_B_7),
177 CUR_BUF_CFG => Registers.CUR_BUF_CFG_B,
178 CUR_WM => PLANE_WM_Type'(
179 Registers.CUR_WM_B_0,
180 Registers.CUR_WM_B_1,
181 Registers.CUR_WM_B_2,
182 Registers.CUR_WM_B_3,
183 Registers.CUR_WM_B_4,
184 Registers.CUR_WM_B_5,
185 Registers.CUR_WM_B_6,
186 Registers.CUR_WM_B_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100187 Tertiary => Controller_Type'
188 (Pipe => Tertiary,
Nico Huber83693c82016-10-08 22:17:55 +0200189 PIPESRC => Registers.PIPECSRC,
190 PIPEMISC => Registers.PIPECMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100191 PF_CTRL => Registers.PFC_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200192 PF_WIN_POS => Registers.PFC_WIN_POS,
193 PF_WIN_SZ => Registers.PFC_WIN_SZ,
194 DSPCNTR => Registers.DSPCCNTR,
195 DSPLINOFF => Registers.DSPCLINOFF,
196 DSPSTRIDE => Registers.DSPCSTRIDE,
197 DSPSURF => Registers.DSPCSURF,
198 DSPTILEOFF => Registers.DSPCTILEOFF,
199 SPCNTR => Registers.SPCCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200200 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,
Nico Huber4dc4c612018-01-10 15:55:09 +0100221 Registers.PLANE_WM_1_C_7),
222 CUR_BUF_CFG => Registers.CUR_BUF_CFG_C,
223 CUR_WM => PLANE_WM_Type'(
224 Registers.CUR_WM_C_0,
225 Registers.CUR_WM_C_1,
226 Registers.CUR_WM_C_2,
227 Registers.CUR_WM_C_3,
228 Registers.CUR_WM_C_4,
229 Registers.CUR_WM_C_5,
230 Registers.CUR_WM_C_6,
231 Registers.CUR_WM_C_7)));
Nico Huber83693c82016-10-08 22:17:55 +0200232
Nico Huber75a707f2018-06-18 16:28:33 +0200233 type Cursor_Regs is record
234 CTL : Registers.Registers_Index;
235 BASE : Registers.Registers_Index;
236 POS : Registers.Registers_Index;
237 FBC_CTL : Registers.Registers_Invalid_Index;
238 end record;
239
240 function Cursors (Pipe : Pipe_Index) return Cursor_Regs is
241 (if not Config.Has_Ivybridge_Cursors then
242 (if Pipe = Primary then
243 (CTL => Registers.CURACNTR,
244 BASE => Registers.CURABASE,
245 POS => Registers.CURAPOS,
246 FBC_CTL => Registers.Invalid_Register)
247 else
248 (CTL => Registers.CURBCNTR,
249 BASE => Registers.CURBBASE,
250 POS => Registers.CURBPOS,
251 FBC_CTL => Registers.Invalid_Register))
252 else
253 (if Pipe = Primary then
254 (CTL => Registers.CUR_CTL_A,
255 BASE => Registers.CUR_BASE_A,
256 POS => Registers.CUR_POS_A,
257 FBC_CTL => Registers.CUR_FBC_CTL_A)
258 elsif Pipe = Secondary then
259 (CTL => Registers.CUR_CTL_B,
260 BASE => Registers.CUR_BASE_B,
261 POS => Registers.CUR_POS_B,
262 FBC_CTL => Registers.CUR_FBC_CTL_B)
263 else
264 (CTL => Registers.CUR_CTL_C,
265 BASE => Registers.CUR_BASE_C,
266 POS => Registers.CUR_POS_C,
267 FBC_CTL => Registers.CUR_FBC_CTL_C)));
268
Nico Huber83693c82016-10-08 22:17:55 +0200269end HW.GFX.GMA.Pipe_Setup;