| 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 |
| 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 | |
| 15 | with HW.GFX.GMA.Registers; |
| 16 | |
| 17 | with HW.Debug; |
| 18 | with GNAT.Source_Info; |
| 19 | |
| 20 | package body HW.GFX.GMA.PCH.HDMI |
| 21 | is |
| 22 | |
| 23 | PCH_HDMI_ENABLE : constant := 1 * 2 ** 31; |
| 24 | PCH_HDMI_COLOR_FORMAT_8BPC : constant := 0 * 2 ** 26; |
| 25 | PCH_HDMI_COLOR_FORMAT_12BPC : constant := 3 * 2 ** 26; |
| 26 | PCH_HDMI_COLOR_FORMAT_MASK : constant := 7 * 2 ** 26; |
| 27 | PCH_HDMI_SDVO_ENCODING_SDVO : constant := 0 * 2 ** 10; |
| 28 | PCH_HDMI_SDVO_ENCODING_HDMI : constant := 2 * 2 ** 10; |
| 29 | PCH_HDMI_SDVO_ENCODING_MASK : constant := 3 * 2 ** 10; |
| 30 | PCH_HDMI_VSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 4; |
| 31 | PCH_HDMI_HSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 3; |
| 32 | PCH_HDMI_PORT_DETECT : constant := 1 * 2 ** 2; |
| 33 | |
| Nico Huber | 63dc919 | 2018-06-09 17:42:19 +0200 | [diff] [blame] | 34 | function PCH_HDMI_MASK return Word32 is |
| 35 | (PCH_TRANSCODER_SELECT_MASK or |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 36 | PCH_HDMI_ENABLE or |
| 37 | PCH_HDMI_COLOR_FORMAT_MASK or |
| 38 | PCH_HDMI_SDVO_ENCODING_MASK or |
| 39 | PCH_HDMI_HSYNC_ACTIVE_HIGH or |
| Nico Huber | 63dc919 | 2018-06-09 17:42:19 +0200 | [diff] [blame] | 40 | PCH_HDMI_VSYNC_ACTIVE_HIGH); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 41 | |
| Tim Wawrzynczak | 605660b | 2022-06-08 12:48:19 -0600 | [diff] [blame^] | 42 | type PCH_HDMI_Array is array (IRL_PCH_HDMI_Port) of Registers.Registers_Index; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 43 | PCH_HDMI : constant PCH_HDMI_Array := PCH_HDMI_Array' |
| 44 | (PCH_HDMI_B => Registers.PCH_HDMIB, |
| 45 | PCH_HDMI_C => Registers.PCH_HDMIC, |
| 46 | PCH_HDMI_D => Registers.PCH_HDMID); |
| 47 | |
| 48 | ---------------------------------------------------------------------------- |
| 49 | |
| 50 | procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type) |
| 51 | is |
| 52 | Polarity : constant Word32 := |
| 53 | (if Port_Cfg.Mode.H_Sync_Active_High then |
| 54 | PCH_HDMI_HSYNC_ACTIVE_HIGH else 0) or |
| 55 | (if Port_Cfg.Mode.V_Sync_Active_High then |
| 56 | PCH_HDMI_VSYNC_ACTIVE_HIGH else 0); |
| 57 | begin |
| 58 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 59 | |
| 60 | -- registers are just sufficient for setup with DVI adaptor |
| 61 | |
| 62 | Registers.Unset_And_Set_Mask |
| 63 | (Register => PCH_HDMI (Port_Cfg.PCH_Port), |
| 64 | Mask_Unset => PCH_HDMI_MASK, |
| 65 | Mask_Set => PCH_HDMI_ENABLE or |
| 66 | PCH_TRANSCODER_SELECT (FDI_Port) or |
| 67 | PCH_HDMI_SDVO_ENCODING_HDMI or |
| 68 | Polarity); |
| Nico Huber | 04c1d01 | 2019-10-03 22:28:21 +0200 | [diff] [blame] | 69 | Registers.Posting_Read (PCH_HDMI (Port_Cfg.PCH_Port)); |
| 70 | -- Set enable a second time, hardware may miss the first. |
| 71 | Registers.Set_Mask (PCH_HDMI (Port_Cfg.PCH_Port), PCH_HDMI_ENABLE); |
| 72 | Registers.Posting_Read (PCH_HDMI (Port_Cfg.PCH_Port)); |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 73 | end On; |
| 74 | |
| 75 | ---------------------------------------------------------------------------- |
| 76 | |
| Tim Wawrzynczak | 605660b | 2022-06-08 12:48:19 -0600 | [diff] [blame^] | 77 | procedure Off (Port : IRL_PCH_HDMI_Port) |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 78 | is |
| Nico Huber | f6a2d18 | 2019-10-01 10:37:49 +0200 | [diff] [blame] | 79 | With_Transcoder_B_Enabled : Boolean := False; |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 80 | begin |
| 81 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 82 | |
| Nico Huber | f6a2d18 | 2019-10-01 10:37:49 +0200 | [diff] [blame] | 83 | if not Config.Has_Trans_DP_Ctl then |
| 84 | -- Ensure transcoder select isn't set to B, |
| 85 | -- disabled HDMI may block DP otherwise. |
| 86 | Registers.Is_Set_Mask |
| 87 | (Register => PCH_HDMI (Port), |
| 88 | Mask => PCH_HDMI_ENABLE or |
| 89 | PCH_TRANSCODER_SELECT (FDI_B), |
| 90 | Result => With_Transcoder_B_Enabled); |
| 91 | end if; |
| 92 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 93 | Registers.Unset_And_Set_Mask |
| 94 | (Register => PCH_HDMI (Port), |
| 95 | Mask_Unset => PCH_HDMI_MASK, |
| 96 | Mask_Set => PCH_HDMI_HSYNC_ACTIVE_HIGH or |
| 97 | PCH_HDMI_VSYNC_ACTIVE_HIGH); |
| Nico Huber | f6a2d18 | 2019-10-01 10:37:49 +0200 | [diff] [blame] | 98 | Registers.Posting_Read (PCH_HDMI (Port)); |
| 99 | |
| 100 | if not Config.Has_Trans_DP_Ctl and then With_Transcoder_B_Enabled then |
| 101 | -- Reenable with transcoder A selected to switch. |
| 102 | Registers.Set_Mask (PCH_HDMI (Port), PCH_HDMI_ENABLE); |
| 103 | Registers.Posting_Read (PCH_HDMI (Port)); |
| Nico Huber | 04c1d01 | 2019-10-03 22:28:21 +0200 | [diff] [blame] | 104 | -- Set enable a second time, hardware may miss the first. |
| 105 | Registers.Set_Mask (PCH_HDMI (Port), PCH_HDMI_ENABLE); |
| 106 | Registers.Posting_Read (PCH_HDMI (Port)); |
| Nico Huber | f6a2d18 | 2019-10-01 10:37:49 +0200 | [diff] [blame] | 107 | Registers.Unset_Mask (PCH_HDMI (Port), PCH_HDMI_ENABLE); |
| 108 | Registers.Posting_Read (PCH_HDMI (Port)); |
| 109 | end if; |
| 110 | |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 111 | end Off; |
| 112 | |
| 113 | procedure All_Off |
| 114 | is |
| 115 | begin |
| 116 | pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); |
| 117 | |
| Tim Wawrzynczak | 605660b | 2022-06-08 12:48:19 -0600 | [diff] [blame^] | 118 | for Port in IRL_PCH_HDMI_Port loop |
| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 119 | Off (Port); |
| 120 | end loop; |
| 121 | end All_Off; |
| 122 | |
| 123 | end HW.GFX.GMA.PCH.HDMI; |