blob: 465cf082cf24c8070d42dadeb849d23cbf841df4 [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
6-- the Free Software Foundation; version 2 of the License.
7--
8-- This program is distributed in the hope that it will be useful,
9-- but WITHOUT ANY WARRANTY; without even the implied warranty of
10-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11-- GNU General Public License for more details.
12--
13
14with HW.Time;
15with HW.Port_IO;
16
17package HW.GFX.GMA
18with
19 Abstract_State =>
20 (State,
21 Init_State,
22 Config_State,
23 (Device_State with External)),
24 Initializes =>
25 (Init_State,
26 Config_State)
27is
28
29 type CPU_Type is
30 (Ironlake,
31 Sandybridge,
32 Ivybridge,
33 Haswell,
34 Broadwell,
35 Skylake);
36
37 type CPU_Variant is (Normal, ULT);
38
39 type Port_Type is
40 (Disabled,
41 Internal,
42 DP1,
43 DP2,
44 DP3,
45 Digital1,
46 Digital2,
47 Digital3,
48 Analog);
49 type Port_List_Range is range 0 .. 7;
50 type Port_List is array (Port_List_Range) of Port_Type;
51
52 type Config_Type is record
53 Port : Port_Type;
54 Framebuffer : Framebuffer_Type;
55 Mode : Mode_Type;
56 end record;
57 type Config_Index is (Primary, Secondary, Tertiary);
58 type Configs_Type is array (Config_Index) of Config_Type;
59
60 procedure Initialize
61 (MMIO_Base : in Word64 := 0;
62 Write_Delay : in Word64 := 0;
63 Success : out Boolean)
64 with
65 Global =>
66 (In_Out => (Config_State, Device_State, Port_IO.State),
67 Output => (State, Init_State),
68 Input => (Time.State)),
69 Post => Success = Is_Initialized;
70 function Is_Initialized return Boolean
71 with
72 Global => (Input => Init_State);
73
74 procedure Legacy_VGA_Off;
75
76 procedure Scan_Ports
77 (Configs : out Configs_Type;
78 Ports : in Port_List);
79 procedure Auto_Configure
80 (Configs : in out Configs_Type;
81 Keep_Power : in Boolean := False);
82 procedure Update_Outputs (Configs : Configs_Type);
83
84 pragma Warnings (GNATprove, Off, "subprogram ""Dump_Configs"" has no effect",
85 Reason => "It's only used for debugging");
86 procedure Dump_Configs (Configs : Configs_Type);
87
88 type GTT_Address_Type is mod 2 ** 39;
89 type GTT_Range is range 0 .. 16#8_0000# - 1;
90 procedure Write_GTT
91 (GTT_Page : GTT_Range;
92 Device_Address : GTT_Address_Type;
93 Valid : Boolean);
94
95 procedure Setup_Default_GTT (FB : Framebuffer_Type; Phys_FB : Word32);
96
97private
98
99 type GPU_Port is (DIGI_A, DIGI_B, DIGI_C, DIGI_D, DIGI_E);
100
101 subtype Digital_Port is GPU_Port range DIGI_A .. DIGI_E;
102
103 type PCH_Port is
104 (PCH_DAC, PCH_LVDS,
105 PCH_HDMI_B, PCH_HDMI_C, PCH_HDMI_D,
106 PCH_DP_B, PCH_DP_C, PCH_DP_D);
107
108 subtype PCH_HDMI_Port is PCH_Port range PCH_HDMI_B .. PCH_HDMI_D;
109 subtype PCH_DP_Port is PCH_Port range PCH_DP_B .. PCH_DP_D;
110
111 type Display_Type is (None, LVDS, DP, HDMI, VGA);
112
113 subtype Internal_Type is Display_Type range None .. DP;
114
115 type Port_Config is
116 record
117 Port : GPU_Port;
118 PCH_Port : GMA.PCH_Port;
119 Display : Display_Type;
120 Mode : Mode_Type;
121 Is_FDI : Boolean;
122 FDI : DP_Link;
123 DP : DP_Link;
124 end record;
125
126 type FDI_Training_Type is (Simple_Training, Full_Training, Auto_Training);
127
128 ----------------------------------------------------------------------------
129
130 type DP_Port is (DP_A, DP_B, DP_C, DP_D);
131
132 ----------------------------------------------------------------------------
133
134 VGA_SR_INDEX : constant Port_IO.Port_Type := 16#03c4#;
135 VGA_SR_DATA : constant Port_IO.Port_Type := 16#03c5#;
136 VGA_SR01 : constant Word8 := 16#01#;
137
138end HW.GFX.GMA;