blob: 75dde9ef261a7a254d3e67fdbf52ded96564102d [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
Nico Huber247adf32017-06-12 14:39:11 +02002-- Copyright (C) 2015-2017 secunet Security Networks AG
Nico Huber83693c82016-10-08 22:17:55 +02003--
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.Time;
16with HW.Port_IO;
17
18package HW.GFX.GMA
19with
20 Abstract_State =>
21 (State,
22 Init_State,
23 Config_State,
24 (Device_State with External)),
25 Initializes =>
26 (Init_State,
27 Config_State)
28is
29
30 type CPU_Type is
31 (Ironlake,
32 Sandybridge,
33 Ivybridge,
34 Haswell,
35 Broadwell,
Nico Huber21da5742017-01-20 14:00:53 +010036 Broxton,
Nico Huber83693c82016-10-08 22:17:55 +020037 Skylake);
38
39 type CPU_Variant is (Normal, ULT);
40
41 type Port_Type is
42 (Disabled,
43 Internal,
44 DP1,
45 DP2,
46 DP3,
Nico Huber0d454cd2016-11-21 13:33:43 +010047 HDMI1, -- or DVI
48 HDMI2, -- or DVI
49 HDMI3, -- or DVI
Nico Huber83693c82016-10-08 22:17:55 +020050 Analog);
Nico Huber83693c82016-10-08 22:17:55 +020051
Nico Huber99f10f32016-11-20 00:34:05 +010052 type Pipe_Config is record
Nico Huber83693c82016-10-08 22:17:55 +020053 Port : Port_Type;
54 Framebuffer : Framebuffer_Type;
55 Mode : Mode_Type;
56 end record;
Nico Huber99f10f32016-11-20 00:34:05 +010057 type Pipe_Index is (Primary, Secondary, Tertiary);
58 type Pipe_Configs is array (Pipe_Index) of Pipe_Config;
Nico Huber83693c82016-10-08 22:17:55 +020059
Nico Huber3675db52016-11-04 16:27:29 +010060 -- Special framebuffer offset to indicate legacy VGA plane.
61 -- Only valid on primary pipe.
62 VGA_PLANE_FRAMEBUFFER_OFFSET : constant := 16#ffff_ffff#;
63
Nico Huberbebca132017-06-12 23:04:46 +020064 pragma Warnings (GNATprove, Off, "unused variable ""Write_Delay""",
65 Reason => "Write_Delay is used for debugging only");
Nico Huber83693c82016-10-08 22:17:55 +020066 procedure Initialize
Nico Huber2b6f6992017-07-09 18:11:34 +020067 (Write_Delay : in Word64 := 0;
Nico Huber793a8d42016-11-21 18:57:03 +010068 Clean_State : in Boolean := False;
Nico Huber83693c82016-10-08 22:17:55 +020069 Success : out Boolean)
70 with
71 Global =>
72 (In_Out => (Config_State, Device_State, Port_IO.State),
73 Output => (State, Init_State),
74 Input => (Time.State)),
75 Post => Success = Is_Initialized;
76 function Is_Initialized return Boolean
77 with
78 Global => (Input => Init_State);
Nico Huberbebca132017-06-12 23:04:46 +020079 pragma Warnings (GNATprove, On, "unused variable ""Write_Delay""");
Nico Huber83693c82016-10-08 22:17:55 +020080
Nico Huber99f10f32016-11-20 00:34:05 +010081 procedure Update_Outputs (Configs : Pipe_Configs);
Nico Huber83693c82016-10-08 22:17:55 +020082
83 pragma Warnings (GNATprove, Off, "subprogram ""Dump_Configs"" has no effect",
84 Reason => "It's only used for debugging");
Nico Huber99f10f32016-11-20 00:34:05 +010085 procedure Dump_Configs (Configs : Pipe_Configs);
Nico Huber83693c82016-10-08 22:17:55 +020086
87 type GTT_Address_Type is mod 2 ** 39;
88 type GTT_Range is range 0 .. 16#8_0000# - 1;
89 procedure Write_GTT
90 (GTT_Page : GTT_Range;
91 Device_Address : GTT_Address_Type;
92 Valid : Boolean);
93
94 procedure Setup_Default_GTT (FB : Framebuffer_Type; Phys_FB : Word32);
95
96private
97
Nico Huber8c45bcf2016-11-20 17:30:57 +010098 ----------------------------------------------------------------------------
99 -- State tracking for the currently configured pipes
100
101 Cur_Configs : Pipe_Configs with Part_Of => State;
102
103 ----------------------------------------------------------------------------
104 -- Internal representation of a single pipe's configuration
105
106 subtype Active_Port_Type is Port_Type
107 range Port_Type'Succ (Disabled) .. Port_Type'Last;
108
Nico Huber83693c82016-10-08 22:17:55 +0200109 type GPU_Port is (DIGI_A, DIGI_B, DIGI_C, DIGI_D, DIGI_E);
110
111 subtype Digital_Port is GPU_Port range DIGI_A .. DIGI_E;
112
113 type PCH_Port is
114 (PCH_DAC, PCH_LVDS,
115 PCH_HDMI_B, PCH_HDMI_C, PCH_HDMI_D,
116 PCH_DP_B, PCH_DP_C, PCH_DP_D);
117
118 subtype PCH_HDMI_Port is PCH_Port range PCH_HDMI_B .. PCH_HDMI_D;
119 subtype PCH_DP_Port is PCH_Port range PCH_DP_B .. PCH_DP_D;
120
Nico Huber83693c82016-10-08 22:17:55 +0200121 type Port_Config is
122 record
123 Port : GPU_Port;
124 PCH_Port : GMA.PCH_Port;
125 Display : Display_Type;
126 Mode : Mode_Type;
127 Is_FDI : Boolean;
128 FDI : DP_Link;
129 DP : DP_Link;
130 end record;
131
132 type FDI_Training_Type is (Simple_Training, Full_Training, Auto_Training);
133
134 ----------------------------------------------------------------------------
135
136 type DP_Port is (DP_A, DP_B, DP_C, DP_D);
137
Nico Huber247adf32017-06-12 14:39:11 +0200138 ----------------------------------------------------------------------------
139
140 subtype DDI_HDMI_Buf_Trans_Range is Integer range 0 .. 11;
141
Nico Huber83693c82016-10-08 22:17:55 +0200142end HW.GFX.GMA;