blob: 4c84f36d7ffe3ad5fd9eb0132688c0ac5172e4fd [file] [log] [blame]
Arthur Heymans73ea0322018-03-28 17:17:07 +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; either version 2 of the License, or
7-- (at your option) any later version.
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
15with HW.GFX.GMA.Registers;
16
17with HW.Debug;
18with GNAT.Source_Info;
19
20package body HW.GFX.GMA.GMCH.HDMI
21is
22
23 GMCH_HDMI_ENABLE : constant := 1 * 2 ** 31;
24 GMCH_HDMI_COLOR_FORMAT_8BPC : constant := 0 * 2 ** 26;
25 GMCH_HDMI_COLOR_FORMAT_12BPC : constant := 3 * 2 ** 26;
26 GMCH_HDMI_COLOR_FORMAT_MASK : constant := 7 * 2 ** 26;
27 GMCH_HDMI_SDVO_ENCODING_SDVO : constant := 0 * 2 ** 10;
28 GMCH_HDMI_SDVO_ENCODING_HDMI : constant := 2 * 2 ** 10;
29 GMCH_HDMI_SDVO_ENCODING_MASK : constant := 3 * 2 ** 10;
30 GMCH_HDMI_MODE_SELECT_HDMI : constant := 1 * 2 ** 9;
31 GMCH_HDMI_MODE_SELECT_DVI : constant := 0 * 2 ** 9;
32 GMCH_HDMI_VSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 4;
33 GMCH_HDMI_HSYNC_ACTIVE_HIGH : constant := 1 * 2 ** 3;
34 GMCH_HDMI_PORT_DETECT : constant := 1 * 2 ** 2;
35
36 GMCH_HDMI_MASK : constant Word32 :=
37 GMCH_PORT_PIPE_SELECT_MASK or
38 GMCH_HDMI_ENABLE or
39 GMCH_HDMI_COLOR_FORMAT_MASK or
40 GMCH_HDMI_SDVO_ENCODING_MASK or
41 GMCH_HDMI_MODE_SELECT_HDMI or
42 GMCH_HDMI_HSYNC_ACTIVE_HIGH or
43 GMCH_HDMI_VSYNC_ACTIVE_HIGH;
44
45 type GMCH_HDMI_Array is array (GMCH_HDMI_Port) of Registers.Registers_Index;
46 GMCH_HDMI : constant GMCH_HDMI_Array := GMCH_HDMI_Array'
47 (DIGI_B => Registers.GMCH_HDMIB,
48 DIGI_C => Registers.GMCH_HDMIC);
49
50 ----------------------------------------------------------------------------
51
52 procedure On (Port_Cfg : in Port_Config;
53 Pipe : in Pipe_Index)
54 is
55 Polarity : constant Word32 :=
56 (if Port_Cfg.Mode.H_Sync_Active_High then
57 GMCH_HDMI_HSYNC_ACTIVE_HIGH else 0) or
58 (if Port_Cfg.Mode.V_Sync_Active_High then
59 GMCH_HDMI_VSYNC_ACTIVE_HIGH else 0);
60 begin
61 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
62
63 Registers.Unset_And_Set_Mask
64 (Register => GMCH_HDMI (Port_Cfg.Port),
65 Mask_Unset => GMCH_HDMI_MASK,
66 Mask_Set => GMCH_HDMI_ENABLE or
67 GMCH_PORT_PIPE_SELECT (Pipe) or
68 GMCH_HDMI_SDVO_ENCODING_HDMI or
69 GMCH_HDMI_MODE_SELECT_HDMI or
70 Polarity);
71 end On;
72
73 ----------------------------------------------------------------------------
74
75 procedure Off (Port : GMCH_HDMI_Port)
76 is
77 begin
78 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
79
80 Registers.Unset_And_Set_Mask
81 (Register => GMCH_HDMI (Port),
82 Mask_Unset => GMCH_HDMI_MASK,
83 Mask_Set => GMCH_HDMI_HSYNC_ACTIVE_HIGH or
84 GMCH_HDMI_VSYNC_ACTIVE_HIGH);
85 end Off;
86
87 procedure All_Off
88 is
89 begin
90 pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity));
91
92 for Port in GMCH_HDMI_Port loop
93 Off (Port);
94 end loop;
95 end All_Off;
96
97end HW.GFX.GMA.GMCH.HDMI;