blob: ffac9d4375358ec349a485bb8b59c04c53d63fc7 [file] [log] [blame]
Nico Huber8c45bcf2016-11-20 17:30:57 +01001--
Nico Huber3be61d42017-01-09 13:58:18 +01002-- Copyright (C) 2015-2017 secunet Security Networks AG
Nico Huber8c45bcf2016-11-20 17:30:57 +01003--
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
Nico Huber2bbd6e72020-01-07 18:22:59 +010015with HW.GFX.GMA.Config;
Nico Huber8c45bcf2016-11-20 17:30:57 +010016
17private package HW.GFX.GMA.Config_Helpers
18is
19
Nico Huber3be61d42017-01-09 13:58:18 +010020 function To_GPU_Port
21 (Pipe : Pipe_Index;
22 Port : Active_Port_Type)
23 return GPU_Port;
24
Nico Huber8c45bcf2016-11-20 17:30:57 +010025 function To_PCH_Port (Port : Active_Port_Type) return PCH_Port;
26
27 function To_Display_Type (Port : Active_Port_Type) return Display_Type;
28
Nico Huber2bbd6e72020-01-07 18:22:59 +010029 function To_Panel (Port : Active_Port_Type) return Panel_Control;
30
Nico Huber8c45bcf2016-11-20 17:30:57 +010031 procedure Fill_Port_Config
32 (Port_Cfg : out Port_Config;
33 Pipe : in Pipe_Index;
34 Port : in Port_Type;
35 Mode : in Mode_Type;
Nico Huber9a4c4c32019-09-16 22:05:11 +020036 Success : out Boolean)
37 with
38 Post =>
39 (if Success then
40 Port_Cfg.Mode.H_Visible = Mode.H_Visible and
41 Port_Cfg.Mode.V_Visible = Mode.V_Visible);
Nico Huber8c45bcf2016-11-20 17:30:57 +010042
43 ----------------------------------------------------------------------------
44
Nico Huber31a52172017-03-05 14:17:34 +010045 pragma Warnings (GNAT, Off, """Integer_32"" is already use-visible *",
46 Reason => "Needed for older compiler versions");
Nico Huber8c45bcf2016-11-20 17:30:57 +010047 use type HW.Pos32;
Nico Huber31a52172017-03-05 14:17:34 +010048 pragma Warnings (GNAT, On, """Integer_32"" is already use-visible *");
Nico Huber9e96a452019-09-22 20:25:17 +020049
50 -- Validate just enough to satisfy Pipe_Setup pre conditions.
51 function Valid_FB
52 (FB : Framebuffer_Type;
53 Mode : Mode_Type)
54 return Boolean is
55 (Rotated_Width (FB) <= Mode.H_Visible and
56 Rotated_Height (FB) <= Mode.V_Visible and
57 (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
58 FB.Height + FB.Start_Y <= FB.V_Stride));
59
60 -- Also validate that we only use supported values / features.
Nico Huber8c45bcf2016-11-20 17:30:57 +010061 function Validate_Config
Nico Huberf361ec82018-06-02 18:01:45 +020062 (FB : Framebuffer_Type;
63 Mode : Mode_Type;
Nico Huber9a4c4c32019-09-16 22:05:11 +020064 Pipe : Pipe_Index)
Nico Huber8c45bcf2016-11-20 17:30:57 +010065 return Boolean
66 with
Nico Huber9e96a452019-09-22 20:25:17 +020067 Post => (if Validate_Config'Result then Valid_FB (FB, Mode));
Nico Huber8c45bcf2016-11-20 17:30:57 +010068
Nico Huber88da05e2019-09-16 21:03:20 +020069 -- For still active pipes, ensure only timings
70 -- changed that don't affect FB validity.
71 function Stable_FB (Old_C, New_C : Pipe_Configs) return Boolean is
72 (for all P in Pipe_Index =>
73 New_C (P).Port = Disabled or
74 (New_C (P).Port = Old_C (P).Port and
75 New_C (P).Framebuffer = Old_C (P).Framebuffer and
76 New_C (P).Cursor = Old_C (P).Cursor and
77 New_C (P).Mode.H_Visible = Old_C (P).Mode.H_Visible and
78 New_C (P).Mode.V_Visible = Old_C (P).Mode.V_Visible));
79
80 ----------------------------------------------------------------------------
81
82 function Highest_Dotclock (Configs : Pipe_Configs) return Frequency_Type;
83
84 procedure Limit_Dotclocks
85 (Configs : in out Pipe_Configs;
86 Max : in Frequency_Type)
87 with
88 Post => Stable_FB (Configs'Old, Configs);
89
Nico Huber8c45bcf2016-11-20 17:30:57 +010090end HW.GFX.GMA.Config_Helpers;