blob: c5d963189f80d00a38ebb02e9b7b9687ed5b6778 [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
23 -- implementation only supports 4800p for now ;-)
24 subtype Width_Type is Pos32 range 1 .. 4800;
25 subtype Height_Type is Pos32 range 1 .. 7680;
26
27 Auto_BPC : constant := 5;
28 subtype BPC_Type is Int64 range Auto_BPC .. 16;
29
Nico Huber51375ad2017-08-24 14:44:06 +020030 type Tiling_Type is (Linear, X_Tiled, Y_Tiled);
Nico Huberb03c8f12017-08-25 13:29:08 +020031 subtype XY_Tiling is Tiling_Type range X_Tiled .. Y_Tiled;
Nico Huber51375ad2017-08-24 14:44:06 +020032
Nico Huber83693c82016-10-08 22:17:55 +020033 type Framebuffer_Type is
34 record
Nico Huber51375ad2017-08-24 14:44:06 +020035 Width : Width_Type;
36 Height : Height_Type;
37 BPC : BPC_Type;
38 Stride : Width_Type;
39 Tiling : Tiling_Type;
40 Offset : Word32;
Nico Huber83693c82016-10-08 22:17:55 +020041 end record;
42
Nico Huber194e57e2017-07-15 21:15:46 +020043 function FB_Size (FB : Framebuffer_Type) return Pos32 is
44 (FB.Stride * FB.Height * Pos32 (FB.BPC) / (8 / 4));
45
Nico Huber83693c82016-10-08 22:17:55 +020046 Default_FB : constant Framebuffer_Type := Framebuffer_Type'
Nico Huber51375ad2017-08-24 14:44:06 +020047 (Width => 1,
48 Height => 1,
49 BPC => 8,
50 Stride => 1,
51 Tiling => Linear,
52 Offset => 0);
Nico Huber83693c82016-10-08 22:17:55 +020053
Nico Huberf54d0962016-10-20 14:17:18 +020054 subtype Frequency_Type is Pos64 range 24_000_000 .. 600_000_000;
Nico Huber83693c82016-10-08 22:17:55 +020055
56 type DP_Lane_Count is (DP_Lane_Count_1, DP_Lane_Count_2, DP_Lane_Count_4);
57 subtype DP_Lane_Count_Type is Pos64 range 1 .. 4;
58 type DP_Lane_Count_Integers is array (DP_Lane_Count) of DP_Lane_Count_Type;
59 Lane_Count_As_Integer : constant DP_Lane_Count_Integers :=
60 DP_Lane_Count_Integers'
61 (DP_Lane_Count_1 => 1, DP_Lane_Count_2 => 2, DP_Lane_Count_4 => 4);
62
63 type DP_Bandwidth is (DP_Bandwidth_1_62, DP_Bandwidth_2_7, DP_Bandwidth_5_4);
64 for DP_Bandwidth use
65 (DP_Bandwidth_1_62 => 6, DP_Bandwidth_2_7 => 10, DP_Bandwidth_5_4 => 20);
66 for DP_Bandwidth'Size use 8;
67 subtype DP_Symbol_Rate_Type is Pos64 range 1 .. 810_000_000;
68 type DP_Symbol_Rate_Array is array (DP_Bandwidth) of DP_Symbol_Rate_Type;
69 DP_Symbol_Rate : constant DP_Symbol_Rate_Array := DP_Symbol_Rate_Array'
70 (DP_Bandwidth_1_62 => 162_000_000,
71 DP_Bandwidth_2_7 => 270_000_000,
72 DP_Bandwidth_5_4 => 540_000_000);
73
74 type DP_Caps is record
75 Rev : Word8;
76 Max_Link_Rate : DP_Bandwidth;
77 Max_Lane_Count : DP_Lane_Count;
78 TPS3_Supported : Boolean;
79 Enhanced_Framing : Boolean;
80 No_Aux_Handshake : Boolean;
81 Aux_RD_Interval : Word8;
82 end record;
83
84 type DP_Link is
85 record
86 Receiver_Caps : DP_Caps;
87 Lane_Count : DP_Lane_Count;
88 Bandwidth : DP_Bandwidth;
89 Enhanced_Framing : Boolean;
90 Opportunistic_Training : Boolean;
91 end record;
92 Default_DP : constant DP_Link := DP_Link'
93 (Receiver_Caps => DP_Caps'
94 (Rev => 16#00#,
95 Max_Link_Rate => DP_Bandwidth'First,
96 Max_Lane_Count => DP_Lane_Count'First,
97 TPS3_Supported => False,
98 Enhanced_Framing => False,
99 No_Aux_Handshake => False,
100 Aux_RD_Interval => 16#00#),
101 Lane_Count => DP_Lane_Count'First,
102 Bandwidth => DP_Bandwidth'First,
103 Enhanced_Framing => False,
104 Opportunistic_Training => False);
105
Nico Huber393aa8a2016-10-21 14:18:53 +0200106 type Display_Type is (None, LVDS, DP, HDMI, VGA);
107 subtype Internal_Type is Display_Type range None .. DP;
108
Nico Huber83693c82016-10-08 22:17:55 +0200109 type Mode_Type is
110 record
111 Dotclock : Frequency_Type;
112 H_Visible : Pos16;
113 H_Sync_Begin : Pos16;
114 H_Sync_End : Pos16;
115 H_Total : Pos16;
116 V_Visible : Pos16;
117 V_Sync_Begin : Pos16;
118 V_Sync_End : Pos16;
119 V_Total : Pos16;
120 H_Sync_Active_High : Boolean;
121 V_Sync_Active_High : Boolean;
122 BPC : BPC_Type;
123 end record;
124
125 ----------------------------------------------------------------------------
126 -- Constants
127 ----------------------------------------------------------------------------
128
129 -- modeline constants
130 -- Dotclock is calculated using: Refresh_Rate * H_Total * V_Total
131
132 M2560x1600_60 : constant Mode_Type := Mode_Type'
133 (60*(2720*1646), 2560, 2608, 2640, 2720, 1600, 1603, 1609, 1646, True, True, Auto_BPC);
134
135 M2560x1440_60 : constant Mode_Type := Mode_Type'
136 (60*(2720*1481), 2560, 2608, 2640, 2720, 1440, 1443, 1448, 1481, True, False, Auto_BPC);
137
138 M1920x1200_60 : constant Mode_Type := Mode_Type'
139 (60*(2080*1235), 1920, 1968, 2000, 2080, 1200, 1203, 1209, 1235, False, False, Auto_BPC);
140
141 M1920x1080_60 : constant Mode_Type := Mode_Type'
142 (60*(2185*1135), 1920, 2008, 2052, 2185, 1080, 1084, 1089, 1135, False, False, Auto_BPC);
143
144 M1680x1050_60 : constant Mode_Type := Mode_Type'
145 (60*(2256*1087), 1680, 1784, 1968, 2256, 1050, 1051, 1054, 1087, False, True, Auto_BPC);
146
147 M1600x1200_60 : constant Mode_Type := Mode_Type'
148 (60*(2160*1250), 1600, 1664, 1856, 2160, 1200, 1201, 1204, 1250, True, True, Auto_BPC);
149
150 M1600x900_60 : constant Mode_Type := Mode_Type'
151 (60*(2010*912), 1600, 1664, 1706, 2010, 900, 903, 906, 912, False, False, Auto_BPC);
152
153 M1440x900_60 : constant Mode_Type := Mode_Type'
154 (60*(1834*920), 1440, 1488, 1520, 1834, 900, 903, 909, 920, False, False, Auto_BPC);
155
156 M1366x768_60 : constant Mode_Type := Mode_Type'
157 (60*(1446*788), 1366, 1414, 1446, 1466, 768, 769, 773, 788, False, False, Auto_BPC);
158
159 M1280x1024_60 : constant Mode_Type := Mode_Type'
160 (60*(1712*1063), 1280, 1368, 1496, 1712, 1024, 1027, 1034, 1063, False, True, Auto_BPC);
161
162 M1024x768_60 : constant Mode_Type := Mode_Type'
163 (60*(1344*806), 1024, 1048, 1184, 1344, 768, 771, 777, 806, False, False, Auto_BPC);
164
165 Invalid_Mode : constant Mode_Type := Mode_Type'
166 (Frequency_Type'First, 1, 1, 1, 1, 1, 1, 1, 1, False, False, Auto_BPC);
167
168end HW.GFX;