| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 1 | -- |
| Nico Huber | af9cc9e | 2017-01-09 13:11:32 +0100 | [diff] [blame] | 2 | -- Copyright (C) 2015-2017 secunet Security Networks AG |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 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 Huber | 125a29e | 2016-10-18 00:23:54 +0200 | [diff] [blame] | 6 | -- the Free Software Foundation; either version 2 of the License, or |
| 7 | -- (at your option) any later version. |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 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 | |
| Nico Huber | 0bad885 | 2024-07-22 15:22:13 +0200 | [diff] [blame] | 15 | with HW.GFX.DP_Defs; |
| 16 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 17 | with HW.GFX.GMA.Config; |
| 18 | with HW.GFX.GMA.Panel; |
| Angel Pons | 8d5c24d | 2021-03-01 15:59:58 +0100 | [diff] [blame] | 19 | with HW.GFX.GMA.DP_Dual_Mode; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 20 | with HW.GFX.GMA.DP_Info; |
| Nico Huber | 0bad885 | 2024-07-22 15:22:13 +0200 | [diff] [blame] | 21 | with HW.GFX.GMA.DP_Aux_Ch; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 22 | |
| 23 | with HW.Debug; |
| 24 | with GNAT.Source_Info; |
| 25 | |
| 26 | package body HW.GFX.GMA.Connector_Info is |
| 27 | |
| Nico Huber | 995436b | 2016-11-20 02:21:51 +0100 | [diff] [blame] | 28 | procedure Preferred_Link_Setting |
| 29 | (Port_Cfg : in out Port_Config; |
| 30 | Success : out Boolean) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 31 | is |
| Nico Huber | 0bad885 | 2024-07-22 15:22:13 +0200 | [diff] [blame] | 32 | use type Word8; |
| 33 | |
| Nico Huber | 995436b | 2016-11-20 02:21:51 +0100 | [diff] [blame] | 34 | DP_Port : constant GMA.DP_Port := |
| Tim Wawrzynczak | 24748f3 | 2022-09-09 10:54:05 -0600 | [diff] [blame] | 35 | (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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 48 | else |
| Tim Wawrzynczak | 24748f3 | 2022-09-09 10:54:05 -0600 | [diff] [blame] | 49 | (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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 57 | begin |
| 58 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 59 | |
| 60 | if Port_Cfg.Display = DP then |
| Nico Huber | 2bbd6e7 | 2020-01-07 18:22:59 +0100 | [diff] [blame] | 61 | if GMA.Config.Use_PP_VDD_Override then |
| 62 | Panel.VDD_Override (Port_Cfg.Panel); |
| 63 | else |
| 64 | Panel.On (Port_Cfg.Panel); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 65 | end if; |
| 66 | |
| Angel Pons | 8d5c24d | 2021-03-01 15:59:58 +0100 | [diff] [blame] | 67 | DP_Dual_Mode.Switch_LSPCON (DP_Port); |
| 68 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 69 | DP_Info.Read_Caps |
| 70 | (Link => Port_Cfg.DP, |
| Nico Huber | 995436b | 2016-11-20 02:21:51 +0100 | [diff] [blame] | 71 | Port => DP_Port, |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 72 | Success => Success); |
| 73 | if Success then |
| Greg V | 3d3452f | 2019-10-08 02:05:05 +0300 | [diff] [blame] | 74 | DP_Info.Read_eDP_Rates |
| 75 | (Link => Port_Cfg.DP, |
| 76 | Port => DP_Port); |
| 77 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 78 | DP_Info.Preferred_Link_Setting |
| 79 | (Link => Port_Cfg.DP, |
| 80 | Mode => Port_Cfg.Mode, |
| 81 | Success => Success); |
| Nico Huber | af9cc9e | 2017-01-09 13:11:32 +0100 | [diff] [blame] | 82 | pragma Debug (Success, DP_Info.Dump_Link_Setting (Port_Cfg.DP)); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 83 | end if; |
| Nico Huber | 0bad885 | 2024-07-22 15:22:13 +0200 | [diff] [blame] | 84 | |
| 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 Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 101 | 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 Huber | af9cc9e | 2017-01-09 13:11:32 +0100 | [diff] [blame] | 118 | pragma Debug (Success, DP_Info.Dump_Link_Setting (Port_Cfg.DP)); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 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 |
| Jeremy Compostella | e096913 | 2023-08-15 09:29:01 -0700 | [diff] [blame] | 130 | (if (Port_Cfg.Port = DIGI_A and Port_Cfg.Display /= HDMI) or |
| Arthur Heymans | 5d08a93 | 2018-03-28 17:00:18 +0200 | [diff] [blame] | 131 | (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS) or |
| 132 | Port_Cfg.Port = LVDS |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 133 | then 6 |
| 134 | else 8); |
| 135 | end Default_BPC; |
| 136 | |
| 137 | end HW.GFX.GMA.Connector_Info; |