| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 1 | -- |
| 2 | -- Copyright (C) 2015-2016 secunet Security Networks AG |
| 3 | -- Copyright (C) 2016 Nico Huber <nico.h@gmx.de> |
| 4 | -- |
| 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 Huber | 125a29e | 2016-10-18 00:23:54 +0200 | [diff] [blame] | 7 | -- the Free Software Foundation; either version 2 of the License, or |
| 8 | -- (at your option) any later version. |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 9 | -- |
| 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 | |
| 16 | with HW.GFX.GMA.Config; |
| 17 | with HW.GFX.GMA.Panel; |
| 18 | with HW.GFX.GMA.Connectors.EDP; |
| 19 | with HW.GFX.GMA.Connectors.FDI; |
| 20 | with HW.GFX.GMA.PCH.VGA; |
| 21 | with HW.GFX.GMA.PCH.LVDS; |
| 22 | with HW.GFX.GMA.PCH.HDMI; |
| 23 | with HW.GFX.GMA.PCH.DP; |
| 24 | with HW.GFX.GMA.PCH.Transcoder; |
| 25 | |
| 26 | with HW.Debug; |
| 27 | with GNAT.Source_Info; |
| 28 | |
| 29 | package body HW.GFX.GMA.Connectors |
| 30 | is |
| 31 | |
| Nico Huber | 3a0e2a0 | 2017-07-19 14:41:46 +0200 | [diff] [blame] | 32 | procedure Post_Reset_Off is null; |
| 33 | procedure Initialize is null; |
| Nico Huber | 0923b79 | 2017-06-09 15:28:41 +0200 | [diff] [blame] | 34 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 35 | function Is_Internal (Port_Cfg : Port_Config) return Boolean |
| 36 | is |
| 37 | begin |
| 38 | return |
| 39 | Port_Cfg.Port = DIGI_A or |
| 40 | (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS); |
| 41 | end Is_Internal; |
| 42 | |
| 43 | ---------------------------------------------------------------------------- |
| 44 | |
| 45 | procedure Pre_On |
| Nico Huber | 6e327c9 | 2016-12-21 14:45:45 +0100 | [diff] [blame] | 46 | (Pipe : in Pipe_Index; |
| 47 | Port_Cfg : in Port_Config; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 48 | PLL_Hint : in Word32; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 49 | Success : out Boolean) |
| 50 | is |
| 51 | begin |
| 52 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 53 | |
| 54 | if Port_Cfg.Port = DIGI_A then |
| Nico Huber | 6e327c9 | 2016-12-21 14:45:45 +0100 | [diff] [blame] | 55 | EDP.Pre_On (Pipe, Port_Cfg); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 56 | elsif Port_Cfg.Port in FDI.GPU_FDI_Port then |
| 57 | FDI.Pre_On (Port_Cfg); |
| 58 | end if; |
| 59 | Success := True; |
| 60 | end Pre_On; |
| 61 | |
| 62 | procedure Post_On |
| Arthur Heymans | 60d0e5f | 2018-03-28 17:08:27 +0200 | [diff] [blame] | 63 | (Pipe : in Pipe_Index; |
| 64 | Port_Cfg : in Port_Config; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 65 | PLL_Hint : in Word32; |
| 66 | Success : out Boolean) |
| 67 | is |
| 68 | begin |
| 69 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 70 | |
| 71 | if Port_Cfg.Port = DIGI_A then |
| 72 | EDP.Pre_Training; |
| Nico Huber | 2bbd6e7 | 2020-01-07 18:22:59 +0100 | [diff] [blame^] | 73 | Panel.On (Port_Cfg.Panel, Wait => True); |
| Nico Huber | 7892ff6 | 2016-11-21 23:26:00 +0100 | [diff] [blame] | 74 | EDP.Post_On (Port_Cfg.DP, Success); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 75 | elsif Port_Cfg.Port in FDI.GPU_FDI_Port then |
| 76 | declare |
| 77 | FDI_Port : constant PCH.FDI_Port_Type := |
| 78 | FDI.PCH_FDIs (Port_Cfg.Port); |
| 79 | begin |
| 80 | FDI.Post_On (Port_Cfg, Success); |
| 81 | |
| 82 | if Success then |
| 83 | PCH.Transcoder.On (Port_Cfg, FDI_Port, PLL_Hint); |
| 84 | if Port_Cfg.PCH_Port = PCH_DAC then |
| 85 | PCH.VGA.On (FDI_Port, Port_Cfg.Mode); |
| 86 | elsif Port_Cfg.PCH_Port = PCH_LVDS then |
| 87 | PCH.LVDS.On (Port_Cfg, FDI_Port); |
| 88 | elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then |
| 89 | PCH.HDMI.On (Port_Cfg, FDI_Port); |
| 90 | elsif Port_Cfg.PCH_Port in PCH_DP_Port then |
| Nico Huber | f6a2d18 | 2019-10-01 10:37:49 +0200 | [diff] [blame] | 91 | PCH.DP.On (Port_Cfg, FDI_Port, Success); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 92 | end if; |
| 93 | end if; |
| 94 | end; |
| 95 | else |
| 96 | Success := False; |
| 97 | end if; |
| 98 | |
| 99 | if Success and Is_Internal (Port_Cfg) then |
| Nico Huber | 2bbd6e7 | 2020-01-07 18:22:59 +0100 | [diff] [blame^] | 100 | Panel.On (Port_Cfg.Panel, Wait => False); |
| 101 | Panel.Backlight_On (Port_Cfg.Panel); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 102 | end if; |
| 103 | end Post_On; |
| 104 | |
| 105 | ---------------------------------------------------------------------------- |
| 106 | |
| 107 | procedure Pre_Off (Port_Cfg : Port_Config) |
| 108 | is |
| 109 | begin |
| 110 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 111 | |
| 112 | if Is_Internal (Port_Cfg) then |
| Nico Huber | 2bbd6e7 | 2020-01-07 18:22:59 +0100 | [diff] [blame^] | 113 | Panel.Backlight_Off (Port_Cfg.Panel); |
| 114 | Panel.Off (Port_Cfg.Panel); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 115 | end if; |
| 116 | end Pre_Off; |
| 117 | |
| 118 | procedure Post_Off (Port_Cfg : Port_Config) |
| 119 | is |
| 120 | begin |
| 121 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 122 | |
| 123 | if Port_Cfg.Port = DIGI_A then |
| 124 | EDP.Off (Port_Cfg.Port); |
| 125 | elsif Port_Cfg.Port in FDI.GPU_FDI_Port then |
| 126 | declare |
| 127 | FDI_Port : constant PCH.FDI_Port_Type := |
| 128 | FDI.PCH_FDIs (Port_Cfg.Port); |
| 129 | begin |
| 130 | if Port_Cfg.PCH_Port in PCH_DP_Port then |
| 131 | PCH.DP.Off (Port_Cfg.PCH_Port); |
| 132 | end if; |
| 133 | |
| 134 | FDI.Off (Port_Cfg.Port, FDI.Link_Off); |
| 135 | |
| 136 | if Port_Cfg.PCH_Port = PCH_DAC then |
| 137 | PCH.VGA.Off; |
| 138 | elsif Port_Cfg.PCH_Port = PCH_LVDS then |
| 139 | PCH.LVDS.Off; |
| 140 | elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then |
| 141 | PCH.HDMI.Off (Port_Cfg.PCH_Port); |
| 142 | end if; |
| 143 | PCH.Transcoder.Off (FDI_Port); |
| 144 | |
| 145 | FDI.Off (Port_Cfg.Port, FDI.Clock_Off); |
| 146 | end; |
| 147 | end if; |
| 148 | end Post_Off; |
| 149 | |
| 150 | ---------------------------------------------------------------------------- |
| 151 | |
| 152 | procedure Pre_All_Off |
| 153 | is |
| 154 | begin |
| 155 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 156 | |
| Nico Huber | 2bbd6e7 | 2020-01-07 18:22:59 +0100 | [diff] [blame^] | 157 | for P in Valid_Panels loop |
| 158 | Panel.Backlight_Off (P); |
| 159 | Panel.Off (P); |
| 160 | end loop; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 161 | end Pre_All_Off; |
| 162 | |
| 163 | procedure Post_All_Off |
| 164 | is |
| 165 | begin |
| 166 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 167 | |
| 168 | EDP.Off (DIGI_A); |
| 169 | |
| 170 | for Port in FDI.GPU_FDI_Port loop |
| 171 | FDI.Off (Port, FDI.Link_Off); |
| 172 | end loop; |
| 173 | PCH.VGA.Off; |
| 174 | PCH.LVDS.Off; |
| 175 | PCH.HDMI.All_Off; |
| 176 | PCH.DP.All_Off; |
| 177 | for Port in PCH.FDI_Port_Type loop |
| 178 | PCH.Transcoder.Off (Port); |
| 179 | end loop; |
| 180 | for Port in FDI.GPU_FDI_Port loop |
| 181 | FDI.Off (Port, FDI.Clock_Off); |
| 182 | end loop; |
| 183 | end Post_All_Off; |
| 184 | |
| 185 | end HW.GFX.GMA.Connectors; |