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