blob: 0edb0c9650fe84d7d5ab335925504aa90b445ad8 [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 Huber83693c82016-10-08 22:17:55 +020016with HW.GFX.GMA.Registers;
17
Nico Huber47ff0692016-11-04 14:29:39 +010018use type HW.Int32;
19
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
29 Pre =>
Nico Huber9b479412017-08-27 11:55:56 +020030 Rotated_Width (Framebuffer) <= Port_Cfg.Mode.H_Visible and
31 Rotated_Height (Framebuffer) <= Port_Cfg.Mode.V_Visible and
32 (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
Nico Huber5ef4d602017-12-13 13:56:47 +010033 Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
Nico Huber83693c82016-10-08 22:17:55 +020034
Nico Huber7ad2d652016-12-07 15:19:32 +010035 procedure Off (Pipe : Pipe_Index);
Nico Huber83693c82016-10-08 22:17:55 +020036
Nico Huber33912aa2016-12-06 20:36:23 +010037 procedure Legacy_VGA_Off;
38
Nico Huber83693c82016-10-08 22:17:55 +020039 procedure All_Off;
40
Nico Huberf7f537e2018-01-02 14:15:43 +010041 procedure Setup_FB
42 (Pipe : Pipe_Index;
43 Mode : Mode_Type;
44 Framebuffer : Framebuffer_Type)
45 with
46 Pre =>
47 Rotated_Width (Framebuffer) <= Mode.H_Visible and
48 Rotated_Height (Framebuffer) <= Mode.V_Visible and
49 (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
50 Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
Nico Huber83693c82016-10-08 22:17:55 +020051
Nico Huber4dc4c612018-01-10 15:55:09 +010052 procedure Update_Cursor
53 (Pipe : Pipe_Index;
54 FB : Framebuffer_Type;
55 Cursor : Cursor_Type);
56 procedure Place_Cursor
57 (Pipe : Pipe_Index;
58 FB : Framebuffer_Type;
59 Cursor : Cursor_Type);
60
Nico Huberf361ec82018-06-02 18:01:45 +020061 procedure Scaler_Available (Available : out Boolean; Pipe : Pipe_Index);
62
Nico Huber83693c82016-10-08 22:17:55 +020063private
64
65 subtype WM_Levels is Natural range 0 .. 7;
66 type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
67
68 type Controller_Type is
69 record
Nico Huberf3e23662016-12-05 21:33:03 +010070 Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020071 PIPESRC : Registers.Registers_Index;
72 PIPEMISC : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010073 PF_CTRL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020074 PF_WIN_POS : Registers.Registers_Index;
75 PF_WIN_SZ : Registers.Registers_Index;
76 DSPCNTR : Registers.Registers_Index;
77 DSPLINOFF : Registers.Registers_Index;
78 DSPSTRIDE : Registers.Registers_Index;
79 DSPSURF : Registers.Registers_Index;
80 DSPTILEOFF : Registers.Registers_Index;
81 SPCNTR : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020082 -- Skylake registers (partially aliased)
83 PLANE_CTL : Registers.Registers_Index;
84 PLANE_OFFSET : Registers.Registers_Index;
85 PLANE_POS : Registers.Registers_Index;
86 PLANE_SIZE : Registers.Registers_Index;
87 PLANE_STRIDE : Registers.Registers_Index;
88 PLANE_SURF : Registers.Registers_Index;
89 PS_CTRL_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010090 PS_WIN_POS_1 : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020091 PS_WIN_SZ_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010092 PS_CTRL_2 : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +020093 PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
94 WM_LINETIME : Registers.Registers_Index;
95 PLANE_BUF_CFG : Registers.Registers_Index;
96 PLANE_WM : PLANE_WM_Type;
Nico Huber4dc4c612018-01-10 15:55:09 +010097 CUR_BUF_CFG : Registers.Registers_Index;
98 CUR_WM : PLANE_WM_Type;
Nico Huber83693c82016-10-08 22:17:55 +020099 end record;
100
Nico Huberf3e23662016-12-05 21:33:03 +0100101 type Controller_Array is array (Pipe_Index) of Controller_Type;
102
Nico Huberf3e23662016-12-05 21:33:03 +0100103 Controllers : constant Controller_Array :=
104 (Primary => Controller_Type'
105 (Pipe => Primary,
Nico Huber83693c82016-10-08 22:17:55 +0200106 PIPESRC => Registers.PIPEASRC,
107 PIPEMISC => Registers.PIPEAMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100108 PF_CTRL => Registers.PFA_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200109 PF_WIN_POS => Registers.PFA_WIN_POS,
110 PF_WIN_SZ => Registers.PFA_WIN_SZ,
111 DSPCNTR => Registers.DSPACNTR,
112 DSPLINOFF => Registers.DSPALINOFF,
113 DSPSTRIDE => Registers.DSPASTRIDE,
114 DSPSURF => Registers.DSPASURF,
115 DSPTILEOFF => Registers.DSPATILEOFF,
116 SPCNTR => Registers.SPACNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200117 PLANE_CTL => Registers.DSPACNTR,
118 PLANE_OFFSET => Registers.DSPATILEOFF,
119 PLANE_POS => Registers.PLANE_POS_1_A,
120 PLANE_SIZE => Registers.PLANE_SIZE_1_A,
121 PLANE_STRIDE => Registers.DSPASTRIDE,
122 PLANE_SURF => Registers.DSPASURF,
123 PS_CTRL_1 => Registers.PS_CTRL_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100124 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_A,
Nico Huber83693c82016-10-08 22:17:55 +0200125 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100126 PS_CTRL_2 => Registers.PS_CTRL_2_A,
Nico Huber83693c82016-10-08 22:17:55 +0200127 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_A,
128 WM_LINETIME => Registers.WM_LINETIME_A,
129 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_A,
130 PLANE_WM => PLANE_WM_Type'(
131 Registers.PLANE_WM_1_A_0,
132 Registers.PLANE_WM_1_A_1,
133 Registers.PLANE_WM_1_A_2,
134 Registers.PLANE_WM_1_A_3,
135 Registers.PLANE_WM_1_A_4,
136 Registers.PLANE_WM_1_A_5,
137 Registers.PLANE_WM_1_A_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100138 Registers.PLANE_WM_1_A_7),
139 CUR_BUF_CFG => Registers.CUR_BUF_CFG_A,
140 CUR_WM => PLANE_WM_Type'(
141 Registers.CUR_WM_A_0,
142 Registers.CUR_WM_A_1,
143 Registers.CUR_WM_A_2,
144 Registers.CUR_WM_A_3,
145 Registers.CUR_WM_A_4,
146 Registers.CUR_WM_A_5,
147 Registers.CUR_WM_A_6,
148 Registers.CUR_WM_A_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100149 Secondary => Controller_Type'
150 (Pipe => Secondary,
Nico Huber83693c82016-10-08 22:17:55 +0200151 PIPESRC => Registers.PIPEBSRC,
152 PIPEMISC => Registers.PIPEBMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100153 PF_CTRL => Registers.PFB_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200154 PF_WIN_POS => Registers.PFB_WIN_POS,
155 PF_WIN_SZ => Registers.PFB_WIN_SZ,
156 DSPCNTR => Registers.DSPBCNTR,
157 DSPLINOFF => Registers.DSPBLINOFF,
158 DSPSTRIDE => Registers.DSPBSTRIDE,
159 DSPSURF => Registers.DSPBSURF,
160 DSPTILEOFF => Registers.DSPBTILEOFF,
161 SPCNTR => Registers.SPBCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200162 PLANE_CTL => Registers.DSPBCNTR,
163 PLANE_OFFSET => Registers.DSPBTILEOFF,
164 PLANE_POS => Registers.PLANE_POS_1_B,
165 PLANE_SIZE => Registers.PLANE_SIZE_1_B,
166 PLANE_STRIDE => Registers.DSPBSTRIDE,
167 PLANE_SURF => Registers.DSPBSURF,
168 PS_CTRL_1 => Registers.PS_CTRL_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100169 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
Nico Huber83693c82016-10-08 22:17:55 +0200170 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100171 PS_CTRL_2 => Registers.PS_CTRL_2_B,
Nico Huber83693c82016-10-08 22:17:55 +0200172 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B,
173 WM_LINETIME => Registers.WM_LINETIME_B,
174 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B,
175 PLANE_WM => PLANE_WM_Type'(
176 Registers.PLANE_WM_1_B_0,
177 Registers.PLANE_WM_1_B_1,
178 Registers.PLANE_WM_1_B_2,
179 Registers.PLANE_WM_1_B_3,
180 Registers.PLANE_WM_1_B_4,
181 Registers.PLANE_WM_1_B_5,
182 Registers.PLANE_WM_1_B_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100183 Registers.PLANE_WM_1_B_7),
184 CUR_BUF_CFG => Registers.CUR_BUF_CFG_B,
185 CUR_WM => PLANE_WM_Type'(
186 Registers.CUR_WM_B_0,
187 Registers.CUR_WM_B_1,
188 Registers.CUR_WM_B_2,
189 Registers.CUR_WM_B_3,
190 Registers.CUR_WM_B_4,
191 Registers.CUR_WM_B_5,
192 Registers.CUR_WM_B_6,
193 Registers.CUR_WM_B_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100194 Tertiary => Controller_Type'
195 (Pipe => Tertiary,
Nico Huber83693c82016-10-08 22:17:55 +0200196 PIPESRC => Registers.PIPECSRC,
197 PIPEMISC => Registers.PIPECMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100198 PF_CTRL => Registers.PFC_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200199 PF_WIN_POS => Registers.PFC_WIN_POS,
200 PF_WIN_SZ => Registers.PFC_WIN_SZ,
201 DSPCNTR => Registers.DSPCCNTR,
202 DSPLINOFF => Registers.DSPCLINOFF,
203 DSPSTRIDE => Registers.DSPCSTRIDE,
204 DSPSURF => Registers.DSPCSURF,
205 DSPTILEOFF => Registers.DSPCTILEOFF,
206 SPCNTR => Registers.SPCCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200207 PLANE_CTL => Registers.DSPCCNTR,
208 PLANE_OFFSET => Registers.DSPCTILEOFF,
209 PLANE_POS => Registers.PLANE_POS_1_C,
210 PLANE_SIZE => Registers.PLANE_SIZE_1_C,
211 PLANE_STRIDE => Registers.DSPCSTRIDE,
212 PLANE_SURF => Registers.DSPCSURF,
213 PS_CTRL_1 => Registers.PS_CTRL_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100214 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C,
Nico Huber83693c82016-10-08 22:17:55 +0200215 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100216 PS_CTRL_2 => Registers.Invalid_Register,
Nico Huber83693c82016-10-08 22:17:55 +0200217 PS_WIN_SZ_2 => Registers.Invalid_Register,
218 WM_LINETIME => Registers.WM_LINETIME_C,
219 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C,
220 PLANE_WM => PLANE_WM_Type'(
221 Registers.PLANE_WM_1_C_0,
222 Registers.PLANE_WM_1_C_1,
223 Registers.PLANE_WM_1_C_2,
224 Registers.PLANE_WM_1_C_3,
225 Registers.PLANE_WM_1_C_4,
226 Registers.PLANE_WM_1_C_5,
227 Registers.PLANE_WM_1_C_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100228 Registers.PLANE_WM_1_C_7),
229 CUR_BUF_CFG => Registers.CUR_BUF_CFG_C,
230 CUR_WM => PLANE_WM_Type'(
231 Registers.CUR_WM_C_0,
232 Registers.CUR_WM_C_1,
233 Registers.CUR_WM_C_2,
234 Registers.CUR_WM_C_3,
235 Registers.CUR_WM_C_4,
236 Registers.CUR_WM_C_5,
237 Registers.CUR_WM_C_6,
238 Registers.CUR_WM_C_7)));
Nico Huber83693c82016-10-08 22:17:55 +0200239
Nico Huber75a707f2018-06-18 16:28:33 +0200240 type Cursor_Regs is record
241 CTL : Registers.Registers_Index;
242 BASE : Registers.Registers_Index;
243 POS : Registers.Registers_Index;
244 FBC_CTL : Registers.Registers_Invalid_Index;
245 end record;
246
247 function Cursors (Pipe : Pipe_Index) return Cursor_Regs is
248 (if not Config.Has_Ivybridge_Cursors then
249 (if Pipe = Primary then
250 (CTL => Registers.CURACNTR,
251 BASE => Registers.CURABASE,
252 POS => Registers.CURAPOS,
253 FBC_CTL => Registers.Invalid_Register)
254 else
255 (CTL => Registers.CURBCNTR,
256 BASE => Registers.CURBBASE,
257 POS => Registers.CURBPOS,
258 FBC_CTL => Registers.Invalid_Register))
259 else
260 (if Pipe = Primary then
261 (CTL => Registers.CUR_CTL_A,
262 BASE => Registers.CUR_BASE_A,
263 POS => Registers.CUR_POS_A,
264 FBC_CTL => Registers.CUR_FBC_CTL_A)
265 elsif Pipe = Secondary then
266 (CTL => Registers.CUR_CTL_B,
267 BASE => Registers.CUR_BASE_B,
268 POS => Registers.CUR_POS_B,
269 FBC_CTL => Registers.CUR_FBC_CTL_B)
270 else
271 (CTL => Registers.CUR_CTL_C,
272 BASE => Registers.CUR_BASE_C,
273 POS => Registers.CUR_POS_C,
274 FBC_CTL => Registers.CUR_FBC_CTL_C)));
275
Nico Huber83693c82016-10-08 22:17:55 +0200276end HW.GFX.GMA.Pipe_Setup;