blob: e53d85af7c434c1cfdd570680228d261c71dd015 [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.GMA.Registers;
16
17with HW.Debug;
18with GNAT.Source_Info;
19
20package body HW.GFX.GMA.PCH.HDMI
21is
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
34 PCH_HDMI_MASK : constant Word32 :=
35 PCH_TRANSCODER_SELECT_MASK or
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
40 PCH_HDMI_VSYNC_ACTIVE_HIGH;
41
42 type PCH_HDMI_Array is array (PCH_HDMI_Port) of Registers.Registers_Index;
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);
69 end On;
70
71 ----------------------------------------------------------------------------
72
73 procedure Off (Port : PCH_HDMI_Port)
74 is
75 begin
76 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
77
78 Registers.Unset_And_Set_Mask
79 (Register => PCH_HDMI (Port),
80 Mask_Unset => PCH_HDMI_MASK,
81 Mask_Set => PCH_HDMI_HSYNC_ACTIVE_HIGH or
82 PCH_HDMI_VSYNC_ACTIVE_HIGH);
83 end Off;
84
85 procedure All_Off
86 is
87 begin
88 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
89
90 for Port in PCH_HDMI_Port loop
91 Off (Port);
92 end loop;
93 end All_Off;
94
95end HW.GFX.GMA.PCH.HDMI;