blob: a61ff001f4cbe6d6405650e0b4c6c5363802765b [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
Nico Huber83693c82016-10-08 22:17:55 +020022 procedure On
Nico Huberf3e23662016-12-05 21:33:03 +010023 (Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020024 Port_Cfg : Port_Config;
Nico Huber4dc4c612018-01-10 15:55:09 +010025 Framebuffer : Framebuffer_Type;
26 Cursor : Cursor_Type)
Nico Huber47ff0692016-11-04 14:29:39 +010027 with
28 Pre =>
Nico Huber9b479412017-08-27 11:55:56 +020029 Rotated_Width (Framebuffer) <= Port_Cfg.Mode.H_Visible and
30 Rotated_Height (Framebuffer) <= Port_Cfg.Mode.V_Visible and
31 (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
Nico Huber5ef4d602017-12-13 13:56:47 +010032 Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
Nico Huber83693c82016-10-08 22:17:55 +020033
Nico Huber7ad2d652016-12-07 15:19:32 +010034 procedure Off (Pipe : Pipe_Index);
Nico Huber83693c82016-10-08 22:17:55 +020035
Nico Huber33912aa2016-12-06 20:36:23 +010036 procedure Legacy_VGA_Off;
37
Nico Huber83693c82016-10-08 22:17:55 +020038 procedure All_Off;
39
Nico Huberf7f537e2018-01-02 14:15:43 +010040 procedure Setup_FB
41 (Pipe : Pipe_Index;
42 Mode : Mode_Type;
43 Framebuffer : Framebuffer_Type)
44 with
45 Pre =>
46 Rotated_Width (Framebuffer) <= Mode.H_Visible and
47 Rotated_Height (Framebuffer) <= Mode.V_Visible and
48 (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
49 Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
Nico Huber83693c82016-10-08 22:17:55 +020050
Nico Huber4dc4c612018-01-10 15:55:09 +010051 procedure Update_Cursor
52 (Pipe : Pipe_Index;
53 FB : Framebuffer_Type;
54 Cursor : Cursor_Type);
55 procedure Place_Cursor
56 (Pipe : Pipe_Index;
57 FB : Framebuffer_Type;
58 Cursor : Cursor_Type);
59
Nico Huber83693c82016-10-08 22:17:55 +020060private
61
62 subtype WM_Levels is Natural range 0 .. 7;
63 type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
64
65 type Controller_Type is
66 record
Nico Huberf3e23662016-12-05 21:33:03 +010067 Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020068 PIPESRC : Registers.Registers_Index;
69 PIPEMISC : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010070 PF_CTRL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020071 PF_WIN_POS : Registers.Registers_Index;
72 PF_WIN_SZ : Registers.Registers_Index;
73 DSPCNTR : Registers.Registers_Index;
74 DSPLINOFF : Registers.Registers_Index;
75 DSPSTRIDE : Registers.Registers_Index;
76 DSPSURF : Registers.Registers_Index;
77 DSPTILEOFF : Registers.Registers_Index;
78 SPCNTR : Registers.Registers_Index;
Nico Huber4dc4c612018-01-10 15:55:09 +010079 CUR_CTL : Registers.Registers_Index;
80 CUR_BASE : Registers.Registers_Index;
81 CUR_POS : Registers.Registers_Index;
82 CUR_FBC_CTL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020083 -- Skylake registers (partially aliased)
84 PLANE_CTL : Registers.Registers_Index;
85 PLANE_OFFSET : Registers.Registers_Index;
86 PLANE_POS : Registers.Registers_Index;
87 PLANE_SIZE : Registers.Registers_Index;
88 PLANE_STRIDE : Registers.Registers_Index;
89 PLANE_SURF : Registers.Registers_Index;
90 PS_CTRL_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010091 PS_WIN_POS_1 : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020092 PS_WIN_SZ_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010093 PS_CTRL_2 : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +020094 PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
95 WM_LINETIME : Registers.Registers_Index;
96 PLANE_BUF_CFG : Registers.Registers_Index;
97 PLANE_WM : PLANE_WM_Type;
Nico Huber4dc4c612018-01-10 15:55:09 +010098 CUR_BUF_CFG : Registers.Registers_Index;
99 CUR_WM : PLANE_WM_Type;
Nico Huber83693c82016-10-08 22:17:55 +0200100 end record;
101
Nico Huberf3e23662016-12-05 21:33:03 +0100102 type Controller_Array is array (Pipe_Index) of Controller_Type;
103
Nico Huberf3e23662016-12-05 21:33:03 +0100104 Controllers : constant Controller_Array :=
105 (Primary => Controller_Type'
106 (Pipe => Primary,
Nico Huber83693c82016-10-08 22:17:55 +0200107 PIPESRC => Registers.PIPEASRC,
108 PIPEMISC => Registers.PIPEAMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100109 PF_CTRL => Registers.PFA_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200110 PF_WIN_POS => Registers.PFA_WIN_POS,
111 PF_WIN_SZ => Registers.PFA_WIN_SZ,
112 DSPCNTR => Registers.DSPACNTR,
113 DSPLINOFF => Registers.DSPALINOFF,
114 DSPSTRIDE => Registers.DSPASTRIDE,
115 DSPSURF => Registers.DSPASURF,
116 DSPTILEOFF => Registers.DSPATILEOFF,
117 SPCNTR => Registers.SPACNTR,
Nico Huber4dc4c612018-01-10 15:55:09 +0100118 CUR_CTL => Registers.CUR_CTL_A,
119 CUR_BASE => Registers.CUR_BASE_A,
120 CUR_POS => Registers.CUR_POS_A,
121 CUR_FBC_CTL => Registers.CUR_FBC_CTL_A,
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 Huber4dc4c612018-01-10 15:55:09 +0100167 CUR_CTL => Registers.CUR_CTL_B,
168 CUR_BASE => Registers.CUR_BASE_B,
169 CUR_POS => Registers.CUR_POS_B,
170 CUR_FBC_CTL => Registers.CUR_FBC_CTL_B,
Nico Huber83693c82016-10-08 22:17:55 +0200171 PLANE_CTL => Registers.DSPBCNTR,
172 PLANE_OFFSET => Registers.DSPBTILEOFF,
173 PLANE_POS => Registers.PLANE_POS_1_B,
174 PLANE_SIZE => Registers.PLANE_SIZE_1_B,
175 PLANE_STRIDE => Registers.DSPBSTRIDE,
176 PLANE_SURF => Registers.DSPBSURF,
177 PS_CTRL_1 => Registers.PS_CTRL_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100178 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
Nico Huber83693c82016-10-08 22:17:55 +0200179 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100180 PS_CTRL_2 => Registers.PS_CTRL_2_B,
Nico Huber83693c82016-10-08 22:17:55 +0200181 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B,
182 WM_LINETIME => Registers.WM_LINETIME_B,
183 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B,
184 PLANE_WM => PLANE_WM_Type'(
185 Registers.PLANE_WM_1_B_0,
186 Registers.PLANE_WM_1_B_1,
187 Registers.PLANE_WM_1_B_2,
188 Registers.PLANE_WM_1_B_3,
189 Registers.PLANE_WM_1_B_4,
190 Registers.PLANE_WM_1_B_5,
191 Registers.PLANE_WM_1_B_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100192 Registers.PLANE_WM_1_B_7),
193 CUR_BUF_CFG => Registers.CUR_BUF_CFG_B,
194 CUR_WM => PLANE_WM_Type'(
195 Registers.CUR_WM_B_0,
196 Registers.CUR_WM_B_1,
197 Registers.CUR_WM_B_2,
198 Registers.CUR_WM_B_3,
199 Registers.CUR_WM_B_4,
200 Registers.CUR_WM_B_5,
201 Registers.CUR_WM_B_6,
202 Registers.CUR_WM_B_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100203 Tertiary => Controller_Type'
204 (Pipe => Tertiary,
Nico Huber83693c82016-10-08 22:17:55 +0200205 PIPESRC => Registers.PIPECSRC,
206 PIPEMISC => Registers.PIPECMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100207 PF_CTRL => Registers.PFC_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200208 PF_WIN_POS => Registers.PFC_WIN_POS,
209 PF_WIN_SZ => Registers.PFC_WIN_SZ,
210 DSPCNTR => Registers.DSPCCNTR,
211 DSPLINOFF => Registers.DSPCLINOFF,
212 DSPSTRIDE => Registers.DSPCSTRIDE,
213 DSPSURF => Registers.DSPCSURF,
214 DSPTILEOFF => Registers.DSPCTILEOFF,
215 SPCNTR => Registers.SPCCNTR,
Nico Huber4dc4c612018-01-10 15:55:09 +0100216 CUR_CTL => Registers.CUR_CTL_C,
217 CUR_BASE => Registers.CUR_BASE_C,
218 CUR_POS => Registers.CUR_POS_C,
219 CUR_FBC_CTL => Registers.CUR_FBC_CTL_C,
Nico Huber83693c82016-10-08 22:17:55 +0200220 PLANE_CTL => Registers.DSPCCNTR,
221 PLANE_OFFSET => Registers.DSPCTILEOFF,
222 PLANE_POS => Registers.PLANE_POS_1_C,
223 PLANE_SIZE => Registers.PLANE_SIZE_1_C,
224 PLANE_STRIDE => Registers.DSPCSTRIDE,
225 PLANE_SURF => Registers.DSPCSURF,
226 PS_CTRL_1 => Registers.PS_CTRL_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100227 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C,
Nico Huber83693c82016-10-08 22:17:55 +0200228 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100229 PS_CTRL_2 => Registers.Invalid_Register,
Nico Huber83693c82016-10-08 22:17:55 +0200230 PS_WIN_SZ_2 => Registers.Invalid_Register,
231 WM_LINETIME => Registers.WM_LINETIME_C,
232 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C,
233 PLANE_WM => PLANE_WM_Type'(
234 Registers.PLANE_WM_1_C_0,
235 Registers.PLANE_WM_1_C_1,
236 Registers.PLANE_WM_1_C_2,
237 Registers.PLANE_WM_1_C_3,
238 Registers.PLANE_WM_1_C_4,
239 Registers.PLANE_WM_1_C_5,
240 Registers.PLANE_WM_1_C_6,
Nico Huber4dc4c612018-01-10 15:55:09 +0100241 Registers.PLANE_WM_1_C_7),
242 CUR_BUF_CFG => Registers.CUR_BUF_CFG_C,
243 CUR_WM => PLANE_WM_Type'(
244 Registers.CUR_WM_C_0,
245 Registers.CUR_WM_C_1,
246 Registers.CUR_WM_C_2,
247 Registers.CUR_WM_C_3,
248 Registers.CUR_WM_C_4,
249 Registers.CUR_WM_C_5,
250 Registers.CUR_WM_C_6,
251 Registers.CUR_WM_C_7)));
Nico Huber83693c82016-10-08 22:17:55 +0200252
Nico Huber83693c82016-10-08 22:17:55 +0200253end HW.GFX.GMA.Pipe_Setup;