blob: 7122eacf7656b3be1c1f42484908d3c16418fd64 [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
Nico Huberaf9cc9e2017-01-09 13:11:32 +01002-- Copyright (C) 2015-2017 secunet Security Networks AG
Nico Huber83693c82016-10-08 22:17:55 +02003--
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
Nico Huber0bad8852024-07-22 15:22:13 +020015with HW.GFX.DP_Defs;
16
Nico Huber83693c82016-10-08 22:17:55 +020017with HW.GFX.GMA.Config;
18with HW.GFX.GMA.Panel;
Angel Pons8d5c24d2021-03-01 15:59:58 +010019with HW.GFX.GMA.DP_Dual_Mode;
Nico Huber83693c82016-10-08 22:17:55 +020020with HW.GFX.GMA.DP_Info;
Nico Huber0bad8852024-07-22 15:22:13 +020021with HW.GFX.GMA.DP_Aux_Ch;
Nico Huber83693c82016-10-08 22:17:55 +020022
23with HW.Debug;
24with GNAT.Source_Info;
25
26package body HW.GFX.GMA.Connector_Info is
27
Nico Huber995436b2016-11-20 02:21:51 +010028 procedure Preferred_Link_Setting
29 (Port_Cfg : in out Port_Config;
30 Success : out Boolean)
Nico Huber83693c82016-10-08 22:17:55 +020031 is
Nico Huber0bad8852024-07-22 15:22:13 +020032 use type Word8;
33
Nico Huber995436b2016-11-20 02:21:51 +010034 DP_Port : constant GMA.DP_Port :=
Tim Wawrzynczak24748f32022-09-09 10:54:05 -060035 (if Config.Has_Type_C_Ports
36 then
37 (case Port_Cfg.Port is
38 when DIGI_A => DP_A,
39 when DIGI_B => DP_B,
40 when DIGI_C => DP_C,
41 when DDI_TC1 => DP_D,
42 when DDI_TC2 => DP_E,
43 when DDI_TC3 => DP_F,
44 when DDI_TC4 => DP_G,
45 when DDI_TC5 => DP_H,
46 when DDI_TC6 => DP_I,
47 when others => GMA.DP_Port'First)
Nico Huber83693c82016-10-08 22:17:55 +020048 else
Tim Wawrzynczak24748f32022-09-09 10:54:05 -060049 (if Port_Cfg.Port = DIGI_A then
50 DP_A
51 else
52 (case Port_Cfg.PCH_Port is
53 when PCH_DP_B => DP_B,
54 when PCH_DP_C => DP_C,
55 when PCH_DP_D => DP_D,
56 when others => GMA.DP_Port'First)));
Nico Huber83693c82016-10-08 22:17:55 +020057 begin
58 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
59
60 if Port_Cfg.Display = DP then
Nico Huber2bbd6e72020-01-07 18:22:59 +010061 if GMA.Config.Use_PP_VDD_Override then
62 Panel.VDD_Override (Port_Cfg.Panel);
63 else
64 Panel.On (Port_Cfg.Panel);
Nico Huber83693c82016-10-08 22:17:55 +020065 end if;
66
Angel Pons8d5c24d2021-03-01 15:59:58 +010067 DP_Dual_Mode.Switch_LSPCON (DP_Port);
68
Nico Huber83693c82016-10-08 22:17:55 +020069 DP_Info.Read_Caps
70 (Link => Port_Cfg.DP,
Nico Huber995436b2016-11-20 02:21:51 +010071 Port => DP_Port,
Nico Huber83693c82016-10-08 22:17:55 +020072 Success => Success);
73 if Success then
Greg V3d3452f2019-10-08 02:05:05 +030074 DP_Info.Read_eDP_Rates
75 (Link => Port_Cfg.DP,
76 Port => DP_Port);
77
Nico Huber83693c82016-10-08 22:17:55 +020078 DP_Info.Preferred_Link_Setting
79 (Link => Port_Cfg.DP,
80 Mode => Port_Cfg.Mode,
81 Success => Success);
Nico Huberaf9cc9e2017-01-09 13:11:32 +010082 pragma Debug (Success, DP_Info.Dump_Link_Setting (Port_Cfg.DP));
Nico Huber83693c82016-10-08 22:17:55 +020083 end if;
Nico Huber0bad8852024-07-22 15:22:13 +020084
85 -- Get DP sinks out of power-save mode
86 if Success and Port_Cfg.DP.Receiver_Caps.Rev >= 16#11# then
87 declare
88 DPCD_SINK_CONTROL : constant := 16#00600#;
89 DPCD_SINK_CONTROL_D0 : constant DP_Defs.Aux_Payload :=
90 (1 * 2 ** 0, others => 0);
91 Ignored : Boolean;
92 begin
93 DP_Aux_Ch.Aux_Write
94 (Port => DP_Port,
95 Address => DPCD_SINK_CONTROL,
96 Length => 1,
97 Data => DPCD_SINK_CONTROL_D0,
98 Success => Ignored);
99 end;
100 end if;
Nico Huber83693c82016-10-08 22:17:55 +0200101 else
102 Success := True;
103 end if;
104 end Preferred_Link_Setting;
105
106 procedure Next_Link_Setting
107 (Port_Cfg : in out Port_Config;
108 Success : out Boolean)
109 is
110 begin
111 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
112
113 if Port_Cfg.Display = DP then
114 DP_Info.Next_Link_Setting
115 (Link => Port_Cfg.DP,
116 Mode => Port_Cfg.Mode,
117 Success => Success);
Nico Huberaf9cc9e2017-01-09 13:11:32 +0100118 pragma Debug (Success, DP_Info.Dump_Link_Setting (Port_Cfg.DP));
Nico Huber83693c82016-10-08 22:17:55 +0200119 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
Jeremy Compostellae0969132023-08-15 09:29:01 -0700130 (if (Port_Cfg.Port = DIGI_A and Port_Cfg.Display /= HDMI) or
Arthur Heymans5d08a932018-03-28 17:00:18 +0200131 (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS) or
132 Port_Cfg.Port = LVDS
Nico Huber83693c82016-10-08 22:17:55 +0200133 then 6
134 else 8);
135 end Default_BPC;
136
137end HW.GFX.GMA.Connector_Info;