blob: 3ef5dcf36cb3fb2d27363853254b422740a31b8f [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 Huberf3e23662016-12-05 21:33:03 +010039 procedure Update_Offset (Pipe : Pipe_Index; Framebuffer : Framebuffer_Type);
Nico Huber83693c82016-10-08 22:17:55 +020040
41private
42
43 subtype WM_Levels is Natural range 0 .. 7;
44 type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
45
46 type Controller_Type is
47 record
Nico Huberf3e23662016-12-05 21:33:03 +010048 Pipe : Pipe_Index;
Nico Huber83693c82016-10-08 22:17:55 +020049 PIPESRC : Registers.Registers_Index;
50 PIPEMISC : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010051 PF_CTRL : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020052 PF_WIN_POS : Registers.Registers_Index;
53 PF_WIN_SZ : Registers.Registers_Index;
54 DSPCNTR : Registers.Registers_Index;
55 DSPLINOFF : Registers.Registers_Index;
56 DSPSTRIDE : Registers.Registers_Index;
57 DSPSURF : Registers.Registers_Index;
58 DSPTILEOFF : Registers.Registers_Index;
59 SPCNTR : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020060 -- Skylake registers (partially aliased)
61 PLANE_CTL : Registers.Registers_Index;
62 PLANE_OFFSET : Registers.Registers_Index;
63 PLANE_POS : Registers.Registers_Index;
64 PLANE_SIZE : Registers.Registers_Index;
65 PLANE_STRIDE : Registers.Registers_Index;
66 PLANE_SURF : Registers.Registers_Index;
67 PS_CTRL_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010068 PS_WIN_POS_1 : Registers.Registers_Index;
Nico Huber83693c82016-10-08 22:17:55 +020069 PS_WIN_SZ_1 : Registers.Registers_Index;
Nico Huber4916e342016-11-04 14:37:53 +010070 PS_CTRL_2 : Registers.Registers_Invalid_Index;
Nico Huber83693c82016-10-08 22:17:55 +020071 PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
72 WM_LINETIME : Registers.Registers_Index;
73 PLANE_BUF_CFG : Registers.Registers_Index;
74 PLANE_WM : PLANE_WM_Type;
75 end record;
76
Nico Huberf3e23662016-12-05 21:33:03 +010077 type Controller_Array is array (Pipe_Index) of Controller_Type;
78
Nico Huberf3e23662016-12-05 21:33:03 +010079 Controllers : constant Controller_Array :=
80 (Primary => Controller_Type'
81 (Pipe => Primary,
Nico Huber83693c82016-10-08 22:17:55 +020082 PIPESRC => Registers.PIPEASRC,
83 PIPEMISC => Registers.PIPEAMISC,
Nico Huber4916e342016-11-04 14:37:53 +010084 PF_CTRL => Registers.PFA_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +020085 PF_WIN_POS => Registers.PFA_WIN_POS,
86 PF_WIN_SZ => Registers.PFA_WIN_SZ,
87 DSPCNTR => Registers.DSPACNTR,
88 DSPLINOFF => Registers.DSPALINOFF,
89 DSPSTRIDE => Registers.DSPASTRIDE,
90 DSPSURF => Registers.DSPASURF,
91 DSPTILEOFF => Registers.DSPATILEOFF,
92 SPCNTR => Registers.SPACNTR,
Nico Huber83693c82016-10-08 22:17:55 +020093 PLANE_CTL => Registers.DSPACNTR,
94 PLANE_OFFSET => Registers.DSPATILEOFF,
95 PLANE_POS => Registers.PLANE_POS_1_A,
96 PLANE_SIZE => Registers.PLANE_SIZE_1_A,
97 PLANE_STRIDE => Registers.DSPASTRIDE,
98 PLANE_SURF => Registers.DSPASURF,
99 PS_CTRL_1 => Registers.PS_CTRL_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100100 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_A,
Nico Huber83693c82016-10-08 22:17:55 +0200101 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_A,
Nico Huber4916e342016-11-04 14:37:53 +0100102 PS_CTRL_2 => Registers.PS_CTRL_2_A,
Nico Huber83693c82016-10-08 22:17:55 +0200103 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_A,
104 WM_LINETIME => Registers.WM_LINETIME_A,
105 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_A,
106 PLANE_WM => PLANE_WM_Type'(
107 Registers.PLANE_WM_1_A_0,
108 Registers.PLANE_WM_1_A_1,
109 Registers.PLANE_WM_1_A_2,
110 Registers.PLANE_WM_1_A_3,
111 Registers.PLANE_WM_1_A_4,
112 Registers.PLANE_WM_1_A_5,
113 Registers.PLANE_WM_1_A_6,
114 Registers.PLANE_WM_1_A_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100115 Secondary => Controller_Type'
116 (Pipe => Secondary,
Nico Huber83693c82016-10-08 22:17:55 +0200117 PIPESRC => Registers.PIPEBSRC,
118 PIPEMISC => Registers.PIPEBMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100119 PF_CTRL => Registers.PFB_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200120 PF_WIN_POS => Registers.PFB_WIN_POS,
121 PF_WIN_SZ => Registers.PFB_WIN_SZ,
122 DSPCNTR => Registers.DSPBCNTR,
123 DSPLINOFF => Registers.DSPBLINOFF,
124 DSPSTRIDE => Registers.DSPBSTRIDE,
125 DSPSURF => Registers.DSPBSURF,
126 DSPTILEOFF => Registers.DSPBTILEOFF,
127 SPCNTR => Registers.SPBCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200128 PLANE_CTL => Registers.DSPBCNTR,
129 PLANE_OFFSET => Registers.DSPBTILEOFF,
130 PLANE_POS => Registers.PLANE_POS_1_B,
131 PLANE_SIZE => Registers.PLANE_SIZE_1_B,
132 PLANE_STRIDE => Registers.DSPBSTRIDE,
133 PLANE_SURF => Registers.DSPBSURF,
134 PS_CTRL_1 => Registers.PS_CTRL_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100135 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
Nico Huber83693c82016-10-08 22:17:55 +0200136 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
Nico Huber4916e342016-11-04 14:37:53 +0100137 PS_CTRL_2 => Registers.PS_CTRL_2_B,
Nico Huber83693c82016-10-08 22:17:55 +0200138 PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B,
139 WM_LINETIME => Registers.WM_LINETIME_B,
140 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B,
141 PLANE_WM => PLANE_WM_Type'(
142 Registers.PLANE_WM_1_B_0,
143 Registers.PLANE_WM_1_B_1,
144 Registers.PLANE_WM_1_B_2,
145 Registers.PLANE_WM_1_B_3,
146 Registers.PLANE_WM_1_B_4,
147 Registers.PLANE_WM_1_B_5,
148 Registers.PLANE_WM_1_B_6,
149 Registers.PLANE_WM_1_B_7)),
Nico Huberf3e23662016-12-05 21:33:03 +0100150 Tertiary => Controller_Type'
151 (Pipe => Tertiary,
Nico Huber83693c82016-10-08 22:17:55 +0200152 PIPESRC => Registers.PIPECSRC,
153 PIPEMISC => Registers.PIPECMISC,
Nico Huber4916e342016-11-04 14:37:53 +0100154 PF_CTRL => Registers.PFC_CTL_1,
Nico Huber83693c82016-10-08 22:17:55 +0200155 PF_WIN_POS => Registers.PFC_WIN_POS,
156 PF_WIN_SZ => Registers.PFC_WIN_SZ,
157 DSPCNTR => Registers.DSPCCNTR,
158 DSPLINOFF => Registers.DSPCLINOFF,
159 DSPSTRIDE => Registers.DSPCSTRIDE,
160 DSPSURF => Registers.DSPCSURF,
161 DSPTILEOFF => Registers.DSPCTILEOFF,
162 SPCNTR => Registers.SPCCNTR,
Nico Huber83693c82016-10-08 22:17:55 +0200163 PLANE_CTL => Registers.DSPCCNTR,
164 PLANE_OFFSET => Registers.DSPCTILEOFF,
165 PLANE_POS => Registers.PLANE_POS_1_C,
166 PLANE_SIZE => Registers.PLANE_SIZE_1_C,
167 PLANE_STRIDE => Registers.DSPCSTRIDE,
168 PLANE_SURF => Registers.DSPCSURF,
169 PS_CTRL_1 => Registers.PS_CTRL_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100170 PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C,
Nico Huber83693c82016-10-08 22:17:55 +0200171 PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C,
Nico Huber4916e342016-11-04 14:37:53 +0100172 PS_CTRL_2 => Registers.Invalid_Register,
Nico Huber83693c82016-10-08 22:17:55 +0200173 PS_WIN_SZ_2 => Registers.Invalid_Register,
174 WM_LINETIME => Registers.WM_LINETIME_C,
175 PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C,
176 PLANE_WM => PLANE_WM_Type'(
177 Registers.PLANE_WM_1_C_0,
178 Registers.PLANE_WM_1_C_1,
179 Registers.PLANE_WM_1_C_2,
180 Registers.PLANE_WM_1_C_3,
181 Registers.PLANE_WM_1_C_4,
182 Registers.PLANE_WM_1_C_5,
183 Registers.PLANE_WM_1_C_6,
184 Registers.PLANE_WM_1_C_7)));
185
Nico Huber83693c82016-10-08 22:17:55 +0200186end HW.GFX.GMA.Pipe_Setup;