| 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 |
| 7 | -- the Free Software Foundation; version 2 of the License. |
| 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.GFX.GMA.Config; |
| 16 | with HW.GFX.GMA.Panel; |
| 17 | with HW.GFX.GMA.Connectors.EDP; |
| 18 | with HW.GFX.GMA.Connectors.FDI; |
| 19 | with HW.GFX.GMA.PCH.VGA; |
| 20 | with HW.GFX.GMA.PCH.LVDS; |
| 21 | with HW.GFX.GMA.PCH.HDMI; |
| 22 | with HW.GFX.GMA.PCH.DP; |
| 23 | with HW.GFX.GMA.PCH.Transcoder; |
| 24 | |
| 25 | with HW.Debug; |
| 26 | with GNAT.Source_Info; |
| 27 | |
| 28 | package body HW.GFX.GMA.Connectors |
| 29 | is |
| 30 | |
| 31 | function Is_Internal (Port_Cfg : Port_Config) return Boolean |
| 32 | is |
| 33 | begin |
| 34 | return |
| 35 | Port_Cfg.Port = DIGI_A or |
| 36 | (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS); |
| 37 | end Is_Internal; |
| 38 | |
| 39 | ---------------------------------------------------------------------------- |
| 40 | |
| 41 | procedure Pre_On |
| 42 | (Port_Cfg : in Port_Config; |
| 43 | PLL_Hint : in Word32; |
| 44 | Pipe_Hint : in Word32; |
| 45 | Success : out Boolean) |
| 46 | is |
| 47 | begin |
| 48 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 49 | |
| 50 | if Port_Cfg.Port = DIGI_A then |
| 51 | EDP.Pre_On (Port_Cfg, Pipe_Hint); |
| 52 | elsif Port_Cfg.Port in FDI.GPU_FDI_Port then |
| 53 | FDI.Pre_On (Port_Cfg); |
| 54 | end if; |
| 55 | Success := True; |
| 56 | end Pre_On; |
| 57 | |
| 58 | procedure Post_On |
| 59 | (Port_Cfg : in Port_Config; |
| 60 | PLL_Hint : in Word32; |
| 61 | Success : out Boolean) |
| 62 | is |
| 63 | begin |
| 64 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 65 | |
| 66 | if Port_Cfg.Port = DIGI_A then |
| 67 | EDP.Pre_Training; |
| 68 | Success := True; |
| 69 | elsif Port_Cfg.Port in FDI.GPU_FDI_Port then |
| 70 | declare |
| 71 | FDI_Port : constant PCH.FDI_Port_Type := |
| 72 | FDI.PCH_FDIs (Port_Cfg.Port); |
| 73 | begin |
| 74 | FDI.Post_On (Port_Cfg, Success); |
| 75 | |
| 76 | if Success then |
| 77 | PCH.Transcoder.On (Port_Cfg, FDI_Port, PLL_Hint); |
| 78 | if Port_Cfg.PCH_Port = PCH_DAC then |
| 79 | PCH.VGA.On (FDI_Port, Port_Cfg.Mode); |
| 80 | elsif Port_Cfg.PCH_Port = PCH_LVDS then |
| 81 | PCH.LVDS.On (Port_Cfg, FDI_Port); |
| 82 | elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then |
| 83 | PCH.HDMI.On (Port_Cfg, FDI_Port); |
| 84 | elsif Port_Cfg.PCH_Port in PCH_DP_Port then |
| 85 | PCH.DP.On (Port_Cfg, Success); |
| 86 | end if; |
| 87 | end if; |
| 88 | end; |
| 89 | else |
| 90 | Success := False; |
| 91 | end if; |
| 92 | |
| 93 | if Success and Is_Internal (Port_Cfg) then |
| 94 | Panel.On; |
| 95 | end if; |
| 96 | |
| 97 | if Port_Cfg.Port = DIGI_A then |
| 98 | EDP.Post_On (Port_Cfg.DP, Success); |
| 99 | end if; |
| 100 | |
| 101 | if Success and Is_Internal (Port_Cfg) then |
| 102 | Panel.Backlight_On; |
| 103 | end if; |
| 104 | end Post_On; |
| 105 | |
| 106 | ---------------------------------------------------------------------------- |
| 107 | |
| 108 | procedure Pre_Off (Port_Cfg : Port_Config) |
| 109 | is |
| 110 | begin |
| 111 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 112 | |
| 113 | if Is_Internal (Port_Cfg) then |
| 114 | Panel.Backlight_Off; |
| 115 | Panel.Off; |
| 116 | end if; |
| 117 | end Pre_Off; |
| 118 | |
| 119 | procedure Post_Off (Port_Cfg : Port_Config) |
| 120 | is |
| 121 | begin |
| 122 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 123 | |
| 124 | if Port_Cfg.Port = DIGI_A then |
| 125 | EDP.Off (Port_Cfg.Port); |
| 126 | elsif Port_Cfg.Port in FDI.GPU_FDI_Port then |
| 127 | declare |
| 128 | FDI_Port : constant PCH.FDI_Port_Type := |
| 129 | FDI.PCH_FDIs (Port_Cfg.Port); |
| 130 | begin |
| 131 | if Port_Cfg.PCH_Port in PCH_DP_Port then |
| 132 | PCH.DP.Off (Port_Cfg.PCH_Port); |
| 133 | end if; |
| 134 | |
| 135 | FDI.Off (Port_Cfg.Port, FDI.Link_Off); |
| 136 | |
| 137 | if Port_Cfg.PCH_Port = PCH_DAC then |
| 138 | PCH.VGA.Off; |
| 139 | elsif Port_Cfg.PCH_Port = PCH_LVDS then |
| 140 | PCH.LVDS.Off; |
| 141 | elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then |
| 142 | PCH.HDMI.Off (Port_Cfg.PCH_Port); |
| 143 | end if; |
| 144 | PCH.Transcoder.Off (FDI_Port); |
| 145 | |
| 146 | FDI.Off (Port_Cfg.Port, FDI.Clock_Off); |
| 147 | end; |
| 148 | end if; |
| 149 | end Post_Off; |
| 150 | |
| 151 | ---------------------------------------------------------------------------- |
| 152 | |
| 153 | procedure Pre_All_Off |
| 154 | is |
| 155 | begin |
| 156 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 157 | |
| 158 | Panel.Backlight_Off; |
| 159 | Panel.Off; |
| 160 | end Pre_All_Off; |
| 161 | |
| 162 | procedure Post_All_Off |
| 163 | is |
| 164 | begin |
| 165 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 166 | |
| 167 | EDP.Off (DIGI_A); |
| 168 | |
| 169 | for Port in FDI.GPU_FDI_Port loop |
| 170 | FDI.Off (Port, FDI.Link_Off); |
| 171 | end loop; |
| 172 | PCH.VGA.Off; |
| 173 | PCH.LVDS.Off; |
| 174 | PCH.HDMI.All_Off; |
| 175 | PCH.DP.All_Off; |
| 176 | for Port in PCH.FDI_Port_Type loop |
| 177 | PCH.Transcoder.Off (Port); |
| 178 | end loop; |
| 179 | for Port in FDI.GPU_FDI_Port loop |
| 180 | FDI.Off (Port, FDI.Clock_Off); |
| 181 | end loop; |
| 182 | end Post_All_Off; |
| 183 | |
| 184 | end HW.GFX.GMA.Connectors; |