blob: 2ee0c054e052a135e3e5936648e57ae019a7fc49 [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
62 (Port => Port_Cfg.PCH_Port,
63 Address => 16#50#,
64 Length => Raw_EDID_Length,
65 Data => Raw_EDID,
66 Success => Success);
67 end if;
68 exit when not Success; -- don't retry if reading itself failed
69
70 pragma Debug (Debug.Put_Buffer ("EDID", Raw_EDID, Raw_EDID_Length));
71 Success := EDID.Valid (Raw_EDID);
72 exit when Success;
73 end loop;
74 end Read_EDID;
75
76 ----------------------------------------------------------------------------
77
78 procedure Preferred_Link_Setting
79 (Port_Cfg : in out Port_Config;
80 Success : out Boolean) is
81 begin
82 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
83
84 if Port_Cfg.Display = DP then
85 if Port_Cfg.Port = DIGI_A then
86 if GMA.Config.Use_PP_VDD_Override then
87 Panel.VDD_Override;
88 else
89 Panel.On;
90 end if;
91 end if;
92
93 DP_Info.Read_Caps
94 (Link => Port_Cfg.DP,
95 Port => To_DP (Port_Cfg),
96 Success => Success);
97 if Success then
98 DP_Info.Preferred_Link_Setting
99 (Link => Port_Cfg.DP,
100 Mode => Port_Cfg.Mode,
101 Success => Success);
102 end if;
103 else
104 Success := True;
105 end if;
106 end Preferred_Link_Setting;
107
108 procedure Next_Link_Setting
109 (Port_Cfg : in out Port_Config;
110 Success : out Boolean)
111 is
112 begin
113 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
114
115 if Port_Cfg.Display = DP then
116 DP_Info.Next_Link_Setting
117 (Link => Port_Cfg.DP,
118 Mode => Port_Cfg.Mode,
119 Success => Success);
120 else
121 Success := False;
122 end if;
123 end Next_Link_Setting;
124
125 ----------------------------------------------------------------------------
126
127 function Default_BPC (Port_Cfg : Port_Config) return HW.GFX.BPC_Type
128 is
129 begin
130 return
131 (if Port_Cfg.Port = DIGI_A or
132 (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS)
133 then 6
134 else 8);
135 end Default_BPC;
136
137end HW.GFX.GMA.Connector_Info;