blob: 8bf99dbc1e80bdeaf6433b15f3af106c33145525 [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
6-- the Free Software Foundation; version 2 of the License.
7--
8-- This program is distributed in the hope that it will be useful,
9-- but WITHOUT ANY WARRANTY; without even the implied warranty of
10-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11-- GNU General Public License for more details.
12--
13
14with HW.GFX.GMA.Registers;
15
16with HW.Debug;
17with GNAT.Source_Info;
18
19package body HW.GFX.GMA.PCH.HDMI
20is
21
22 PCH_HDMI_ENABLE : constant := 1 * 2 ** 31;
23 PCH_HDMI_COLOR_FORMAT_8BPC : constant := 0 * 2 ** 26;
24 PCH_HDMI_COLOR_FORMAT_12BPC : constant := 3 * 2 ** 26;
25 PCH_HDMI_COLOR_FORMAT_MASK : constant := 7 * 2 ** 26;
26 PCH_HDMI_SDVO_ENCODING_SDVO : constant := 0 * 2 ** 10;
27 PCH_HDMI_SDVO_ENCODING_HDMI : constant := 2 * 2 ** 10;
28 PCH_HDMI_SDVO_ENCODING_MASK : constant := 3 * 2 ** 10;
29 PCH_HDMI_VSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 4;
30 PCH_HDMI_HSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 3;
31 PCH_HDMI_PORT_DETECT : constant := 1 * 2 ** 2;
32
33 PCH_HDMI_MASK : constant Word32 :=
34 PCH_TRANSCODER_SELECT_MASK or
35 PCH_HDMI_ENABLE or
36 PCH_HDMI_COLOR_FORMAT_MASK or
37 PCH_HDMI_SDVO_ENCODING_MASK or
38 PCH_HDMI_HSYNC_ACTIVE_HIGH or
39 PCH_HDMI_VSYNC_ACTIVE_HIGH;
40
41 type PCH_HDMI_Array is array (PCH_HDMI_Port) of Registers.Registers_Index;
42 PCH_HDMI : constant PCH_HDMI_Array := PCH_HDMI_Array'
43 (PCH_HDMI_B => Registers.PCH_HDMIB,
44 PCH_HDMI_C => Registers.PCH_HDMIC,
45 PCH_HDMI_D => Registers.PCH_HDMID);
46
47 ----------------------------------------------------------------------------
48
49 procedure On (Port_Cfg : Port_Config; FDI_Port : FDI_Port_Type)
50 is
51 Polarity : constant Word32 :=
52 (if Port_Cfg.Mode.H_Sync_Active_High then
53 PCH_HDMI_HSYNC_ACTIVE_HIGH else 0) or
54 (if Port_Cfg.Mode.V_Sync_Active_High then
55 PCH_HDMI_VSYNC_ACTIVE_HIGH else 0);
56 begin
57 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
58
59 -- registers are just sufficient for setup with DVI adaptor
60
61 Registers.Unset_And_Set_Mask
62 (Register => PCH_HDMI (Port_Cfg.PCH_Port),
63 Mask_Unset => PCH_HDMI_MASK,
64 Mask_Set => PCH_HDMI_ENABLE or
65 PCH_TRANSCODER_SELECT (FDI_Port) or
66 PCH_HDMI_SDVO_ENCODING_HDMI or
67 Polarity);
68 end On;
69
70 ----------------------------------------------------------------------------
71
72 procedure Off (Port : PCH_HDMI_Port)
73 is
74 begin
75 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
76
77 Registers.Unset_And_Set_Mask
78 (Register => PCH_HDMI (Port),
79 Mask_Unset => PCH_HDMI_MASK,
80 Mask_Set => PCH_HDMI_HSYNC_ACTIVE_HIGH or
81 PCH_HDMI_VSYNC_ACTIVE_HIGH);
82 end Off;
83
84 procedure All_Off
85 is
86 begin
87 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
88
89 for Port in PCH_HDMI_Port loop
90 Off (Port);
91 end loop;
92 end All_Off;
93
94end HW.GFX.GMA.PCH.HDMI;