| 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.Time; |
| 16 | with HW.Port_IO; |
| 17 | |
| 18 | package HW.GFX.GMA |
| 19 | with |
| 20 | Abstract_State => |
| 21 | (State, |
| 22 | Init_State, |
| 23 | Config_State, |
| 24 | (Device_State with External)), |
| 25 | Initializes => |
| 26 | (Init_State, |
| 27 | Config_State) |
| 28 | is |
| 29 | |
| 30 | type CPU_Type is |
| 31 | (Ironlake, |
| 32 | Sandybridge, |
| 33 | Ivybridge, |
| 34 | Haswell, |
| 35 | Broadwell, |
| 36 | Skylake); |
| 37 | |
| 38 | type CPU_Variant is (Normal, ULT); |
| 39 | |
| 40 | type Port_Type is |
| 41 | (Disabled, |
| 42 | Internal, |
| 43 | DP1, |
| 44 | DP2, |
| 45 | DP3, |
| Nico Huber | 0d454cd | 2016-11-21 13:33:43 +0100 | [diff] [blame^] | 46 | HDMI1, -- or DVI |
| 47 | HDMI2, -- or DVI |
| 48 | HDMI3, -- or DVI |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 49 | Analog); |
| 50 | type Port_List_Range is range 0 .. 7; |
| 51 | type Port_List is array (Port_List_Range) of Port_Type; |
| 52 | |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 53 | type Pipe_Config is record |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 54 | Port : Port_Type; |
| 55 | Framebuffer : Framebuffer_Type; |
| 56 | Mode : Mode_Type; |
| 57 | end record; |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 58 | type Pipe_Index is (Primary, Secondary, Tertiary); |
| 59 | type Pipe_Configs is array (Pipe_Index) of Pipe_Config; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 60 | |
| Nico Huber | 3675db5 | 2016-11-04 16:27:29 +0100 | [diff] [blame] | 61 | -- Special framebuffer offset to indicate legacy VGA plane. |
| 62 | -- Only valid on primary pipe. |
| 63 | VGA_PLANE_FRAMEBUFFER_OFFSET : constant := 16#ffff_ffff#; |
| 64 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 65 | procedure Initialize |
| 66 | (MMIO_Base : in Word64 := 0; |
| 67 | Write_Delay : in Word64 := 0; |
| 68 | Success : out Boolean) |
| 69 | with |
| 70 | Global => |
| 71 | (In_Out => (Config_State, Device_State, Port_IO.State), |
| 72 | Output => (State, Init_State), |
| 73 | Input => (Time.State)), |
| 74 | Post => Success = Is_Initialized; |
| 75 | function Is_Initialized return Boolean |
| 76 | with |
| 77 | Global => (Input => Init_State); |
| 78 | |
| 79 | procedure Legacy_VGA_Off; |
| 80 | |
| 81 | procedure Scan_Ports |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 82 | (Configs : out Pipe_Configs; |
| Nico Huber | aa91bb5 | 2016-11-07 12:51:20 +0100 | [diff] [blame] | 83 | Ports : in Port_List; |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 84 | Max_Pipe : in Pipe_Index := Pipe_Index'Last); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 85 | procedure Auto_Configure |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 86 | (Configs : in out Pipe_Configs; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 87 | Keep_Power : in Boolean := False); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 88 | procedure Update_Outputs (Configs : Pipe_Configs); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 89 | |
| 90 | pragma Warnings (GNATprove, Off, "subprogram ""Dump_Configs"" has no effect", |
| 91 | Reason => "It's only used for debugging"); |
| Nico Huber | 99f10f3 | 2016-11-20 00:34:05 +0100 | [diff] [blame] | 92 | procedure Dump_Configs (Configs : Pipe_Configs); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 93 | |
| 94 | type GTT_Address_Type is mod 2 ** 39; |
| 95 | type GTT_Range is range 0 .. 16#8_0000# - 1; |
| 96 | procedure Write_GTT |
| 97 | (GTT_Page : GTT_Range; |
| 98 | Device_Address : GTT_Address_Type; |
| 99 | Valid : Boolean); |
| 100 | |
| 101 | procedure Setup_Default_GTT (FB : Framebuffer_Type; Phys_FB : Word32); |
| 102 | |
| 103 | private |
| 104 | |
| 105 | type GPU_Port is (DIGI_A, DIGI_B, DIGI_C, DIGI_D, DIGI_E); |
| 106 | |
| 107 | subtype Digital_Port is GPU_Port range DIGI_A .. DIGI_E; |
| 108 | |
| 109 | type PCH_Port is |
| 110 | (PCH_DAC, PCH_LVDS, |
| 111 | PCH_HDMI_B, PCH_HDMI_C, PCH_HDMI_D, |
| 112 | PCH_DP_B, PCH_DP_C, PCH_DP_D); |
| 113 | |
| 114 | subtype PCH_HDMI_Port is PCH_Port range PCH_HDMI_B .. PCH_HDMI_D; |
| 115 | subtype PCH_DP_Port is PCH_Port range PCH_DP_B .. PCH_DP_D; |
| 116 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 117 | type Port_Config is |
| 118 | record |
| 119 | Port : GPU_Port; |
| 120 | PCH_Port : GMA.PCH_Port; |
| 121 | Display : Display_Type; |
| 122 | Mode : Mode_Type; |
| 123 | Is_FDI : Boolean; |
| 124 | FDI : DP_Link; |
| 125 | DP : DP_Link; |
| 126 | end record; |
| 127 | |
| 128 | type FDI_Training_Type is (Simple_Training, Full_Training, Auto_Training); |
| 129 | |
| 130 | ---------------------------------------------------------------------------- |
| 131 | |
| 132 | type DP_Port is (DP_A, DP_B, DP_C, DP_D); |
| 133 | |
| 134 | ---------------------------------------------------------------------------- |
| 135 | |
| 136 | VGA_SR_INDEX : constant Port_IO.Port_Type := 16#03c4#; |
| 137 | VGA_SR_DATA : constant Port_IO.Port_Type := 16#03c5#; |
| 138 | VGA_SR01 : constant Word8 := 16#01#; |
| 139 | |
| 140 | end HW.GFX.GMA; |