blob: 5594b18f0d401bdeebe0e712fafdbeb147deb7c2 [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
2-- Copyright (C) 2015-2016 secunet Security Networks AG
Nico Huber194e57e2017-07-15 21:15:46 +02003-- Copyright (C) 2017 Nico Huber <nico.h@gmx.de>
Nico Huber83693c82016-10-08 22:17:55 +02004--
5-- This program is free software; you can redistribute it and/or modify
6-- it under the terms of the GNU General Public License as published by
Nico Huber125a29e2016-10-18 00:23:54 +02007-- the Free Software Foundation; either version 2 of the License, or
8-- (at your option) any later version.
Nico Huber83693c82016-10-08 22:17:55 +02009--
10-- This program is distributed in the hope that it will be useful,
11-- but WITHOUT ANY WARRANTY; without even the implied warranty of
12-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-- GNU General Public License for more details.
14--
15
16with HW;
17
18use type HW.Pos64;
19use type HW.Word32;
20
21package HW.GFX is
22
Nico Huber0164b022017-08-24 15:12:51 +020023 -- such that the count of pixels in any framebuffer may fit
24 subtype Pixel_Type is Pos32 range 1 .. 8192 * 8192;
25
Nico Huberb7470492017-11-30 14:48:35 +010026 -- Allow same range for width and height (for rotated framebuffers)
27 subtype Width_Type is Pos32 range 1 .. 8192;
28 subtype Height_Type is Pos32 range 1 .. 8192;
Nico Huber83693c82016-10-08 22:17:55 +020029
30 Auto_BPC : constant := 5;
31 subtype BPC_Type is Int64 range Auto_BPC .. 16;
32
Nico Huber51375ad2017-08-24 14:44:06 +020033 type Tiling_Type is (Linear, X_Tiled, Y_Tiled);
Nico Huberb03c8f12017-08-25 13:29:08 +020034 subtype XY_Tiling is Tiling_Type range X_Tiled .. Y_Tiled;
Nico Huber51375ad2017-08-24 14:44:06 +020035
Nico Huberb7470492017-11-30 14:48:35 +010036 type Rotation_Type is (No_Rotation, Rotated_90, Rotated_180, Rotated_270);
37
Nico Huber83693c82016-10-08 22:17:55 +020038 type Framebuffer_Type is
39 record
Nico Huber51375ad2017-08-24 14:44:06 +020040 Width : Width_Type;
41 Height : Height_Type;
42 BPC : BPC_Type;
43 Stride : Width_Type;
Nico Huberb7470492017-11-30 14:48:35 +010044 V_Stride : Height_Type;
Nico Huber51375ad2017-08-24 14:44:06 +020045 Tiling : Tiling_Type;
Nico Huberb7470492017-11-30 14:48:35 +010046 Rotation : Rotation_Type;
Nico Huber51375ad2017-08-24 14:44:06 +020047 Offset : Word32;
Nico Huber83693c82016-10-08 22:17:55 +020048 end record;
49
Nico Huber0164b022017-08-24 15:12:51 +020050 function Pixel_To_Bytes (Pixel : Pixel_Type; FB : Framebuffer_Type)
51 return Pos32 is (Pixel * Pos32 (FB.BPC) / (8 / 4));
Nico Huber194e57e2017-07-15 21:15:46 +020052 function FB_Size (FB : Framebuffer_Type) return Pos32 is
Nico Huberb7470492017-11-30 14:48:35 +010053 (Pixel_To_Bytes (FB.Stride * FB.V_Stride, FB));
Nico Huber194e57e2017-07-15 21:15:46 +020054
Nico Huber83693c82016-10-08 22:17:55 +020055 Default_FB : constant Framebuffer_Type := Framebuffer_Type'
Nico Huber51375ad2017-08-24 14:44:06 +020056 (Width => 1,
57 Height => 1,
58 BPC => 8,
59 Stride => 1,
Nico Huberb7470492017-11-30 14:48:35 +010060 V_Stride => 1,
Nico Huber51375ad2017-08-24 14:44:06 +020061 Tiling => Linear,
Nico Huberb7470492017-11-30 14:48:35 +010062 Rotation => No_Rotation,
Nico Huber51375ad2017-08-24 14:44:06 +020063 Offset => 0);
Nico Huber83693c82016-10-08 22:17:55 +020064
Nico Huberf54d0962016-10-20 14:17:18 +020065 subtype Frequency_Type is Pos64 range 24_000_000 .. 600_000_000;
Nico Huber83693c82016-10-08 22:17:55 +020066
67 type DP_Lane_Count is (DP_Lane_Count_1, DP_Lane_Count_2, DP_Lane_Count_4);
68 subtype DP_Lane_Count_Type is Pos64 range 1 .. 4;
69 type DP_Lane_Count_Integers is array (DP_Lane_Count) of DP_Lane_Count_Type;
70 Lane_Count_As_Integer : constant DP_Lane_Count_Integers :=
71 DP_Lane_Count_Integers'
72 (DP_Lane_Count_1 => 1, DP_Lane_Count_2 => 2, DP_Lane_Count_4 => 4);
73
74 type DP_Bandwidth is (DP_Bandwidth_1_62, DP_Bandwidth_2_7, DP_Bandwidth_5_4);
75 for DP_Bandwidth use
76 (DP_Bandwidth_1_62 => 6, DP_Bandwidth_2_7 => 10, DP_Bandwidth_5_4 => 20);
77 for DP_Bandwidth'Size use 8;
78 subtype DP_Symbol_Rate_Type is Pos64 range 1 .. 810_000_000;
79 type DP_Symbol_Rate_Array is array (DP_Bandwidth) of DP_Symbol_Rate_Type;
80 DP_Symbol_Rate : constant DP_Symbol_Rate_Array := DP_Symbol_Rate_Array'
81 (DP_Bandwidth_1_62 => 162_000_000,
82 DP_Bandwidth_2_7 => 270_000_000,
83 DP_Bandwidth_5_4 => 540_000_000);
84
85 type DP_Caps is record
86 Rev : Word8;
87 Max_Link_Rate : DP_Bandwidth;
88 Max_Lane_Count : DP_Lane_Count;
89 TPS3_Supported : Boolean;
90 Enhanced_Framing : Boolean;
91 No_Aux_Handshake : Boolean;
92 Aux_RD_Interval : Word8;
93 end record;
94
95 type DP_Link is
96 record
97 Receiver_Caps : DP_Caps;
98 Lane_Count : DP_Lane_Count;
99 Bandwidth : DP_Bandwidth;
100 Enhanced_Framing : Boolean;
101 Opportunistic_Training : Boolean;
102 end record;
103 Default_DP : constant DP_Link := DP_Link'
104 (Receiver_Caps => DP_Caps'
105 (Rev => 16#00#,
106 Max_Link_Rate => DP_Bandwidth'First,
107 Max_Lane_Count => DP_Lane_Count'First,
108 TPS3_Supported => False,
109 Enhanced_Framing => False,
110 No_Aux_Handshake => False,
111 Aux_RD_Interval => 16#00#),
112 Lane_Count => DP_Lane_Count'First,
113 Bandwidth => DP_Bandwidth'First,
114 Enhanced_Framing => False,
115 Opportunistic_Training => False);
116
Nico Huber393aa8a2016-10-21 14:18:53 +0200117 type Display_Type is (None, LVDS, DP, HDMI, VGA);
118 subtype Internal_Type is Display_Type range None .. DP;
119
Nico Huber83693c82016-10-08 22:17:55 +0200120 type Mode_Type is
121 record
122 Dotclock : Frequency_Type;
123 H_Visible : Pos16;
124 H_Sync_Begin : Pos16;
125 H_Sync_End : Pos16;
126 H_Total : Pos16;
127 V_Visible : Pos16;
128 V_Sync_Begin : Pos16;
129 V_Sync_End : Pos16;
130 V_Total : Pos16;
131 H_Sync_Active_High : Boolean;
132 V_Sync_Active_High : Boolean;
133 BPC : BPC_Type;
134 end record;
135
136 ----------------------------------------------------------------------------
137 -- Constants
138 ----------------------------------------------------------------------------
139
140 -- modeline constants
141 -- Dotclock is calculated using: Refresh_Rate * H_Total * V_Total
142
143 M2560x1600_60 : constant Mode_Type := Mode_Type'
144 (60*(2720*1646), 2560, 2608, 2640, 2720, 1600, 1603, 1609, 1646, True, True, Auto_BPC);
145
146 M2560x1440_60 : constant Mode_Type := Mode_Type'
147 (60*(2720*1481), 2560, 2608, 2640, 2720, 1440, 1443, 1448, 1481, True, False, Auto_BPC);
148
149 M1920x1200_60 : constant Mode_Type := Mode_Type'
150 (60*(2080*1235), 1920, 1968, 2000, 2080, 1200, 1203, 1209, 1235, False, False, Auto_BPC);
151
152 M1920x1080_60 : constant Mode_Type := Mode_Type'
153 (60*(2185*1135), 1920, 2008, 2052, 2185, 1080, 1084, 1089, 1135, False, False, Auto_BPC);
154
155 M1680x1050_60 : constant Mode_Type := Mode_Type'
156 (60*(2256*1087), 1680, 1784, 1968, 2256, 1050, 1051, 1054, 1087, False, True, Auto_BPC);
157
158 M1600x1200_60 : constant Mode_Type := Mode_Type'
159 (60*(2160*1250), 1600, 1664, 1856, 2160, 1200, 1201, 1204, 1250, True, True, Auto_BPC);
160
161 M1600x900_60 : constant Mode_Type := Mode_Type'
162 (60*(2010*912), 1600, 1664, 1706, 2010, 900, 903, 906, 912, False, False, Auto_BPC);
163
164 M1440x900_60 : constant Mode_Type := Mode_Type'
165 (60*(1834*920), 1440, 1488, 1520, 1834, 900, 903, 909, 920, False, False, Auto_BPC);
166
167 M1366x768_60 : constant Mode_Type := Mode_Type'
168 (60*(1446*788), 1366, 1414, 1446, 1466, 768, 769, 773, 788, False, False, Auto_BPC);
169
170 M1280x1024_60 : constant Mode_Type := Mode_Type'
171 (60*(1712*1063), 1280, 1368, 1496, 1712, 1024, 1027, 1034, 1063, False, True, Auto_BPC);
172
173 M1024x768_60 : constant Mode_Type := Mode_Type'
174 (60*(1344*806), 1024, 1048, 1184, 1344, 768, 771, 777, 806, False, False, Auto_BPC);
175
176 Invalid_Mode : constant Mode_Type := Mode_Type'
177 (Frequency_Type'First, 1, 1, 1, 1, 1, 1, 1, 1, False, False, Auto_BPC);
178
179end HW.GFX;