| 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 |
| 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 | |
| 14 | with HW.GFX.I2C; |
| 15 | with HW.GFX.GMA.Config; |
| 16 | with HW.GFX.GMA.Panel; |
| 17 | with HW.GFX.GMA.I2C; |
| 18 | with HW.GFX.GMA.DP_Info; |
| 19 | with HW.GFX.GMA.DP_Aux_Ch; |
| 20 | |
| 21 | with HW.Debug; |
| 22 | with GNAT.Source_Info; |
| 23 | |
| 24 | package body HW.GFX.GMA.Connector_Info is |
| 25 | |
| 26 | function To_DP (Port_Cfg : Port_Config) return DP_Port |
| 27 | is |
| 28 | begin |
| 29 | return |
| 30 | (if Port_Cfg.Port = DIGI_A then |
| 31 | DP_A |
| 32 | else |
| 33 | (case Port_Cfg.PCH_Port is |
| 34 | when PCH_DP_B => DP_B, |
| 35 | when PCH_DP_C => DP_C, |
| 36 | when PCH_DP_D => DP_D, |
| 37 | when others => DP_Port'First)); |
| 38 | end To_DP; |
| 39 | |
| 40 | ---------------------------------------------------------------------------- |
| 41 | |
| 42 | procedure Read_EDID |
| 43 | (Raw_EDID : out EDID.Raw_EDID_Data; |
| 44 | Port_Cfg : in Port_Config; |
| 45 | Success : out Boolean) |
| 46 | is |
| 47 | Raw_EDID_Length : GFX.I2C.Transfer_Length := Raw_EDID'Length; |
| 48 | begin |
| 49 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 50 | |
| 51 | for I in 1 .. 2 loop |
| 52 | if Port_Cfg.Display = DP then |
| 53 | DP_Aux_Ch.I2C_Read |
| 54 | (Port => To_DP (Port_Cfg), |
| 55 | Address => 16#50#, |
| 56 | Length => Raw_EDID_Length, |
| 57 | Data => Raw_EDID, |
| 58 | Success => Success); |
| 59 | else |
| 60 | I2C.I2C_Read |
| 61 | (Port => Port_Cfg.PCH_Port, |
| 62 | Address => 16#50#, |
| 63 | Length => Raw_EDID_Length, |
| 64 | Data => Raw_EDID, |
| 65 | Success => Success); |
| 66 | end if; |
| 67 | exit when not Success; -- don't retry if reading itself failed |
| 68 | |
| 69 | pragma Debug (Debug.Put_Buffer ("EDID", Raw_EDID, Raw_EDID_Length)); |
| 70 | Success := EDID.Valid (Raw_EDID); |
| 71 | exit when Success; |
| 72 | end loop; |
| 73 | end Read_EDID; |
| 74 | |
| 75 | ---------------------------------------------------------------------------- |
| 76 | |
| 77 | procedure Preferred_Link_Setting |
| 78 | (Port_Cfg : in out Port_Config; |
| 79 | Success : out Boolean) is |
| 80 | begin |
| 81 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 82 | |
| 83 | if Port_Cfg.Display = DP then |
| 84 | if Port_Cfg.Port = DIGI_A then |
| 85 | if GMA.Config.Use_PP_VDD_Override then |
| 86 | Panel.VDD_Override; |
| 87 | else |
| 88 | Panel.On; |
| 89 | end if; |
| 90 | end if; |
| 91 | |
| 92 | DP_Info.Read_Caps |
| 93 | (Link => Port_Cfg.DP, |
| 94 | Port => To_DP (Port_Cfg), |
| 95 | Success => Success); |
| 96 | if Success then |
| 97 | DP_Info.Preferred_Link_Setting |
| 98 | (Link => Port_Cfg.DP, |
| 99 | Mode => Port_Cfg.Mode, |
| 100 | Success => Success); |
| 101 | end if; |
| 102 | else |
| 103 | Success := True; |
| 104 | end if; |
| 105 | end Preferred_Link_Setting; |
| 106 | |
| 107 | procedure Next_Link_Setting |
| 108 | (Port_Cfg : in out Port_Config; |
| 109 | Success : out Boolean) |
| 110 | is |
| 111 | begin |
| 112 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 113 | |
| 114 | if Port_Cfg.Display = DP then |
| 115 | DP_Info.Next_Link_Setting |
| 116 | (Link => Port_Cfg.DP, |
| 117 | Mode => Port_Cfg.Mode, |
| 118 | Success => Success); |
| 119 | else |
| 120 | Success := False; |
| 121 | end if; |
| 122 | end Next_Link_Setting; |
| 123 | |
| 124 | ---------------------------------------------------------------------------- |
| 125 | |
| 126 | function Default_BPC (Port_Cfg : Port_Config) return HW.GFX.BPC_Type |
| 127 | is |
| 128 | begin |
| 129 | return |
| 130 | (if Port_Cfg.Port = DIGI_A or |
| 131 | (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS) |
| 132 | then 6 |
| 133 | else 8); |
| 134 | end Default_BPC; |
| 135 | |
| 136 | end HW.GFX.GMA.Connector_Info; |