| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 1 | -- |
| 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 Huber | 125a29e | 2016-10-18 00:23:54 +0200 | [diff] [blame] | 6 | -- the Free Software Foundation; either version 2 of the License, or |
| 7 | -- (at your option) any later version. |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 8 | -- |
| 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 | |
| 15 | with HW; |
| 16 | |
| 17 | use type HW.Pos64; |
| 18 | use type HW.Word32; |
| 19 | |
| 20 | package HW.GFX is |
| 21 | |
| 22 | -- implementation only supports 4800p for now ;-) |
| 23 | subtype Width_Type is Pos32 range 1 .. 4800; |
| 24 | subtype Height_Type is Pos32 range 1 .. 7680; |
| 25 | |
| 26 | Auto_BPC : constant := 5; |
| 27 | subtype BPC_Type is Int64 range Auto_BPC .. 16; |
| 28 | |
| 29 | type Framebuffer_Type is |
| 30 | record |
| 31 | Width : Width_Type; |
| 32 | Height : Height_Type; |
| 33 | BPC : BPC_Type; |
| 34 | Stride : Width_Type; |
| 35 | Offset : Word32; |
| 36 | end record; |
| 37 | |
| 38 | Default_FB : constant Framebuffer_Type := Framebuffer_Type' |
| 39 | (Width => 1, |
| 40 | Height => 1, |
| 41 | BPC => 8, |
| 42 | Stride => 1, |
| 43 | Offset => 0); |
| 44 | |
| Nico Huber | f54d096 | 2016-10-20 14:17:18 +0200 | [diff] [blame] | 45 | subtype Frequency_Type is Pos64 range 24_000_000 .. 600_000_000; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 46 | |
| 47 | type DP_Lane_Count is (DP_Lane_Count_1, DP_Lane_Count_2, DP_Lane_Count_4); |
| 48 | subtype DP_Lane_Count_Type is Pos64 range 1 .. 4; |
| 49 | type DP_Lane_Count_Integers is array (DP_Lane_Count) of DP_Lane_Count_Type; |
| 50 | Lane_Count_As_Integer : constant DP_Lane_Count_Integers := |
| 51 | DP_Lane_Count_Integers' |
| 52 | (DP_Lane_Count_1 => 1, DP_Lane_Count_2 => 2, DP_Lane_Count_4 => 4); |
| 53 | |
| 54 | type DP_Bandwidth is (DP_Bandwidth_1_62, DP_Bandwidth_2_7, DP_Bandwidth_5_4); |
| 55 | for DP_Bandwidth use |
| 56 | (DP_Bandwidth_1_62 => 6, DP_Bandwidth_2_7 => 10, DP_Bandwidth_5_4 => 20); |
| 57 | for DP_Bandwidth'Size use 8; |
| 58 | subtype DP_Symbol_Rate_Type is Pos64 range 1 .. 810_000_000; |
| 59 | type DP_Symbol_Rate_Array is array (DP_Bandwidth) of DP_Symbol_Rate_Type; |
| 60 | DP_Symbol_Rate : constant DP_Symbol_Rate_Array := DP_Symbol_Rate_Array' |
| 61 | (DP_Bandwidth_1_62 => 162_000_000, |
| 62 | DP_Bandwidth_2_7 => 270_000_000, |
| 63 | DP_Bandwidth_5_4 => 540_000_000); |
| 64 | |
| 65 | type DP_Caps is record |
| 66 | Rev : Word8; |
| 67 | Max_Link_Rate : DP_Bandwidth; |
| 68 | Max_Lane_Count : DP_Lane_Count; |
| 69 | TPS3_Supported : Boolean; |
| 70 | Enhanced_Framing : Boolean; |
| 71 | No_Aux_Handshake : Boolean; |
| 72 | Aux_RD_Interval : Word8; |
| 73 | end record; |
| 74 | |
| 75 | type DP_Link is |
| 76 | record |
| 77 | Receiver_Caps : DP_Caps; |
| 78 | Lane_Count : DP_Lane_Count; |
| 79 | Bandwidth : DP_Bandwidth; |
| 80 | Enhanced_Framing : Boolean; |
| 81 | Opportunistic_Training : Boolean; |
| 82 | end record; |
| 83 | Default_DP : constant DP_Link := DP_Link' |
| 84 | (Receiver_Caps => DP_Caps' |
| 85 | (Rev => 16#00#, |
| 86 | Max_Link_Rate => DP_Bandwidth'First, |
| 87 | Max_Lane_Count => DP_Lane_Count'First, |
| 88 | TPS3_Supported => False, |
| 89 | Enhanced_Framing => False, |
| 90 | No_Aux_Handshake => False, |
| 91 | Aux_RD_Interval => 16#00#), |
| 92 | Lane_Count => DP_Lane_Count'First, |
| 93 | Bandwidth => DP_Bandwidth'First, |
| 94 | Enhanced_Framing => False, |
| 95 | Opportunistic_Training => False); |
| 96 | |
| 97 | type Mode_Type is |
| 98 | record |
| 99 | Dotclock : Frequency_Type; |
| 100 | H_Visible : Pos16; |
| 101 | H_Sync_Begin : Pos16; |
| 102 | H_Sync_End : Pos16; |
| 103 | H_Total : Pos16; |
| 104 | V_Visible : Pos16; |
| 105 | V_Sync_Begin : Pos16; |
| 106 | V_Sync_End : Pos16; |
| 107 | V_Total : Pos16; |
| 108 | H_Sync_Active_High : Boolean; |
| 109 | V_Sync_Active_High : Boolean; |
| 110 | BPC : BPC_Type; |
| 111 | end record; |
| 112 | |
| 113 | ---------------------------------------------------------------------------- |
| 114 | -- Constants |
| 115 | ---------------------------------------------------------------------------- |
| 116 | |
| 117 | -- modeline constants |
| 118 | -- Dotclock is calculated using: Refresh_Rate * H_Total * V_Total |
| 119 | |
| 120 | M2560x1600_60 : constant Mode_Type := Mode_Type' |
| 121 | (60*(2720*1646), 2560, 2608, 2640, 2720, 1600, 1603, 1609, 1646, True, True, Auto_BPC); |
| 122 | |
| 123 | M2560x1440_60 : constant Mode_Type := Mode_Type' |
| 124 | (60*(2720*1481), 2560, 2608, 2640, 2720, 1440, 1443, 1448, 1481, True, False, Auto_BPC); |
| 125 | |
| 126 | M1920x1200_60 : constant Mode_Type := Mode_Type' |
| 127 | (60*(2080*1235), 1920, 1968, 2000, 2080, 1200, 1203, 1209, 1235, False, False, Auto_BPC); |
| 128 | |
| 129 | M1920x1080_60 : constant Mode_Type := Mode_Type' |
| 130 | (60*(2185*1135), 1920, 2008, 2052, 2185, 1080, 1084, 1089, 1135, False, False, Auto_BPC); |
| 131 | |
| 132 | M1680x1050_60 : constant Mode_Type := Mode_Type' |
| 133 | (60*(2256*1087), 1680, 1784, 1968, 2256, 1050, 1051, 1054, 1087, False, True, Auto_BPC); |
| 134 | |
| 135 | M1600x1200_60 : constant Mode_Type := Mode_Type' |
| 136 | (60*(2160*1250), 1600, 1664, 1856, 2160, 1200, 1201, 1204, 1250, True, True, Auto_BPC); |
| 137 | |
| 138 | M1600x900_60 : constant Mode_Type := Mode_Type' |
| 139 | (60*(2010*912), 1600, 1664, 1706, 2010, 900, 903, 906, 912, False, False, Auto_BPC); |
| 140 | |
| 141 | M1440x900_60 : constant Mode_Type := Mode_Type' |
| 142 | (60*(1834*920), 1440, 1488, 1520, 1834, 900, 903, 909, 920, False, False, Auto_BPC); |
| 143 | |
| 144 | M1366x768_60 : constant Mode_Type := Mode_Type' |
| 145 | (60*(1446*788), 1366, 1414, 1446, 1466, 768, 769, 773, 788, False, False, Auto_BPC); |
| 146 | |
| 147 | M1280x1024_60 : constant Mode_Type := Mode_Type' |
| 148 | (60*(1712*1063), 1280, 1368, 1496, 1712, 1024, 1027, 1034, 1063, False, True, Auto_BPC); |
| 149 | |
| 150 | M1024x768_60 : constant Mode_Type := Mode_Type' |
| 151 | (60*(1344*806), 1024, 1048, 1184, 1344, 768, 771, 777, 806, False, False, Auto_BPC); |
| 152 | |
| 153 | Invalid_Mode : constant Mode_Type := Mode_Type' |
| 154 | (Frequency_Type'First, 1, 1, 1, 1, 1, 1, 1, 1, False, False, Auto_BPC); |
| 155 | |
| 156 | end HW.GFX; |