blob: 33d543e5dfeda0a50b736fae9abd6f6bc38f6802 [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 Huber47ff0692016-11-04 14:29:39 +010025 Framebuffer : Framebuffer_Type)
26 with
27 Pre =>
Nico Huber9b479412017-08-27 11:55:56 +020028 Rotated_Width (Framebuffer) <= Port_Cfg.Mode.H_Visible and
29 Rotated_Height (Framebuffer) <= Port_Cfg.Mode.V_Visible and
30 (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
Nico Huber5ef4d602017-12-13 13:56:47 +010031 Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
Nico Huber83693c82016-10-08 22:17:55 +020032
Nico Huber7ad2d652016-12-07 15:19:32 +010033 procedure Off (Pipe : Pipe_Index);
Nico Huber83693c82016-10-08 22:17:55 +020034
Nico Huber33912aa2016-12-06 20:36:23 +010035 procedure Legacy_VGA_Off;
36
Nico Huber83693c82016-10-08 22:17:55 +020037 procedure All_Off;
38
Nico Huberf7f537e2018-01-02 14:15:43 +010039 procedure Setup_FB
40 (Pipe : Pipe_Index;
41 Mode : Mode_Type;
42 Framebuffer : Framebuffer_Type)
43 with
44 Pre =>
45 Rotated_Width (Framebuffer) <= Mode.H_Visible and
46 Rotated_Height (Framebuffer) <= Mode.V_Visible and
47 (Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
48 Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
Nico Huber83693c82016-10-08 22:17:55 +020049
50private
51
52 subtype WM_Levels is Natural range 0 .. 7;
53 type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
54
55 type Controller_Type is
56 record
Nico Huberf3e23662016-12-05 21:33:03 +010057 Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020058 PIPESRC : Registers.Registers_Index;
59 PIPEMISC : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010060 PF_CTRL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020061 PF_WIN_POS : Registers.Registers_Index;
62 PF_WIN_SZ : Registers.Registers_Index;
63 DSPCNTR : Registers.Registers_Index;
64 DSPLINOFF : Registers.Registers_Index;
65 DSPSTRIDE : Registers.Registers_Index;
66 DSPSURF : Registers.Registers_Index;
67 DSPTILEOFF : Registers.Registers_Index;
68 SPCNTR : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020069 -- Skylake registers (partially aliased)
70 PLANE_CTL : Registers.Registers_Index;
71 PLANE_OFFSET : Registers.Registers_Index;
72 PLANE_POS : Registers.Registers_Index;
73 PLANE_SIZE : Registers.Registers_Index;
74 PLANE_STRIDE : Registers.Registers_Index;
75 PLANE_SURF : Registers.Registers_Index;
76 PS_CTRL_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010077 PS_WIN_POS_1 : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020078 PS_WIN_SZ_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010079 PS_CTRL_2 : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +020080 PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
81 WM_LINETIME : Registers.Registers_Index;
82 PLANE_BUF_CFG : Registers.Registers_Index;
83 PLANE_WM : PLANE_WM_Type;
84 end record;
85
Nico Huberf3e23662016-12-05 21:33:03 +010086 type Controller_Array is array (Pipe_Index) of Controller_Type;
87
Nico Huberf3e23662016-12-05 21:33:03 +010088 Controllers : constant Controller_Array :=
89 (Primary => Controller_Type'
90 (Pipe => Primary,
Nico Huber83693c82016-10-08 22:17:55 +020091 PIPESRC => Registers.PIPEASRC,
92 PIPEMISC => Registers.PIPEAMISC,
Nico Huber4916e342016-11-04 14:37:53 +010093 PF_CTRL => Registers.PFA_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +020094 PF_WIN_POS => Registers.PFA_WIN_POS,
95 PF_WIN_SZ => Registers.PFA_WIN_SZ,
96 DSPCNTR => Registers.DSPACNTR,
97 DSPLINOFF => Registers.DSPALINOFF,
98 DSPSTRIDE => Registers.DSPASTRIDE,
99 DSPSURF => Registers.DSPASURF,
100 DSPTILEOFF => Registers.DSPATILEOFF,
101 SPCNTR => Registers.SPACNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200102 PLANE_CTL => Registers.DSPACNTR,
103 PLANE_OFFSET => Registers.DSPATILEOFF,
104 PLANE_POS => Registers.PLANE_POS_1_A,
105 PLANE_SIZE => Registers.PLANE_SIZE_1_A,
106 PLANE_STRIDE => Registers.DSPASTRIDE,
107 PLANE_SURF => Registers.DSPASURF,
108 PS_CTRL_1 => Registers.PS_CTRL_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100109 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_A,
Nico Huber83693c82016-10-08 22:17:55 +0200110 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100111 PS_CTRL_2 => Registers.PS_CTRL_2_A,
Nico Huber83693c82016-10-08 22:17:55 +0200112 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_A,
113 WM_LINETIME => Registers.WM_LINETIME_A,
114 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_A,
115 PLANE_WM => PLANE_WM_Type'(
116 Registers.PLANE_WM_1_A_0,
117 Registers.PLANE_WM_1_A_1,
118 Registers.PLANE_WM_1_A_2,
119 Registers.PLANE_WM_1_A_3,
120 Registers.PLANE_WM_1_A_4,
121 Registers.PLANE_WM_1_A_5,
122 Registers.PLANE_WM_1_A_6,
123 Registers.PLANE_WM_1_A_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100124 Secondary => Controller_Type'
125 (Pipe => Secondary,
Nico Huber83693c82016-10-08 22:17:55 +0200126 PIPESRC => Registers.PIPEBSRC,
127 PIPEMISC => Registers.PIPEBMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100128 PF_CTRL => Registers.PFB_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200129 PF_WIN_POS => Registers.PFB_WIN_POS,
130 PF_WIN_SZ => Registers.PFB_WIN_SZ,
131 DSPCNTR => Registers.DSPBCNTR,
132 DSPLINOFF => Registers.DSPBLINOFF,
133 DSPSTRIDE => Registers.DSPBSTRIDE,
134 DSPSURF => Registers.DSPBSURF,
135 DSPTILEOFF => Registers.DSPBTILEOFF,
136 SPCNTR => Registers.SPBCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200137 PLANE_CTL => Registers.DSPBCNTR,
138 PLANE_OFFSET => Registers.DSPBTILEOFF,
139 PLANE_POS => Registers.PLANE_POS_1_B,
140 PLANE_SIZE => Registers.PLANE_SIZE_1_B,
141 PLANE_STRIDE => Registers.DSPBSTRIDE,
142 PLANE_SURF => Registers.DSPBSURF,
143 PS_CTRL_1 => Registers.PS_CTRL_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100144 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
Nico Huber83693c82016-10-08 22:17:55 +0200145 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100146 PS_CTRL_2 => Registers.PS_CTRL_2_B,
Nico Huber83693c82016-10-08 22:17:55 +0200147 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B,
148 WM_LINETIME => Registers.WM_LINETIME_B,
149 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B,
150 PLANE_WM => PLANE_WM_Type'(
151 Registers.PLANE_WM_1_B_0,
152 Registers.PLANE_WM_1_B_1,
153 Registers.PLANE_WM_1_B_2,
154 Registers.PLANE_WM_1_B_3,
155 Registers.PLANE_WM_1_B_4,
156 Registers.PLANE_WM_1_B_5,
157 Registers.PLANE_WM_1_B_6,
158 Registers.PLANE_WM_1_B_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100159 Tertiary => Controller_Type'
160 (Pipe => Tertiary,
Nico Huber83693c82016-10-08 22:17:55 +0200161 PIPESRC => Registers.PIPECSRC,
162 PIPEMISC => Registers.PIPECMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100163 PF_CTRL => Registers.PFC_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200164 PF_WIN_POS => Registers.PFC_WIN_POS,
165 PF_WIN_SZ => Registers.PFC_WIN_SZ,
166 DSPCNTR => Registers.DSPCCNTR,
167 DSPLINOFF => Registers.DSPCLINOFF,
168 DSPSTRIDE => Registers.DSPCSTRIDE,
169 DSPSURF => Registers.DSPCSURF,
170 DSPTILEOFF => Registers.DSPCTILEOFF,
171 SPCNTR => Registers.SPCCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200172 PLANE_CTL => Registers.DSPCCNTR,
173 PLANE_OFFSET => Registers.DSPCTILEOFF,
174 PLANE_POS => Registers.PLANE_POS_1_C,
175 PLANE_SIZE => Registers.PLANE_SIZE_1_C,
176 PLANE_STRIDE => Registers.DSPCSTRIDE,
177 PLANE_SURF => Registers.DSPCSURF,
178 PS_CTRL_1 => Registers.PS_CTRL_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100179 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C,
Nico Huber83693c82016-10-08 22:17:55 +0200180 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100181 PS_CTRL_2 => Registers.Invalid_Register,
Nico Huber83693c82016-10-08 22:17:55 +0200182 PS_WIN_SZ_2 => Registers.Invalid_Register,
183 WM_LINETIME => Registers.WM_LINETIME_C,
184 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C,
185 PLANE_WM => PLANE_WM_Type'(
186 Registers.PLANE_WM_1_C_0,
187 Registers.PLANE_WM_1_C_1,
188 Registers.PLANE_WM_1_C_2,
189 Registers.PLANE_WM_1_C_3,
190 Registers.PLANE_WM_1_C_4,
191 Registers.PLANE_WM_1_C_5,
192 Registers.PLANE_WM_1_C_6,
193 Registers.PLANE_WM_1_C_7)));
194
Nico Huber83693c82016-10-08 22:17:55 +0200195end HW.GFX.GMA.Pipe_Setup;