| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 1 | -- |
| Nico Huber | 3be61d4 | 2017-01-09 13:58:18 +0100 | [diff] [blame] | 2 | -- Copyright (C) 2015-2017 secunet Security Networks AG |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 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 | |
| 15 | with HW; |
| Nico Huber | 2bbd6e7 | 2020-01-07 18:22:59 +0100 | [diff] [blame] | 16 | with HW.GFX.GMA.Config; |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 17 | |
| 18 | private package HW.GFX.GMA.Config_Helpers |
| 19 | is |
| 20 | |
| Nico Huber | 3be61d4 | 2017-01-09 13:58:18 +0100 | [diff] [blame] | 21 | function To_GPU_Port |
| 22 | (Pipe : Pipe_Index; |
| 23 | Port : Active_Port_Type) |
| 24 | return GPU_Port; |
| 25 | |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 26 | function To_PCH_Port (Port : Active_Port_Type) return PCH_Port; |
| 27 | |
| 28 | function To_Display_Type (Port : Active_Port_Type) return Display_Type; |
| 29 | |
| Nico Huber | 2bbd6e7 | 2020-01-07 18:22:59 +0100 | [diff] [blame] | 30 | function To_Panel (Port : Active_Port_Type) return Panel_Control; |
| 31 | |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 32 | procedure Fill_Port_Config |
| 33 | (Port_Cfg : out Port_Config; |
| 34 | Pipe : in Pipe_Index; |
| 35 | Port : in Port_Type; |
| 36 | Mode : in Mode_Type; |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 37 | Success : out Boolean) |
| 38 | with |
| 39 | Post => |
| 40 | (if Success then |
| 41 | Port_Cfg.Mode.H_Visible = Mode.H_Visible and |
| 42 | Port_Cfg.Mode.V_Visible = Mode.V_Visible); |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 43 | |
| 44 | ---------------------------------------------------------------------------- |
| 45 | |
| Nico Huber | 31a5217 | 2017-03-05 14:17:34 +0100 | [diff] [blame] | 46 | pragma Warnings (GNAT, Off, """Integer_32"" is already use-visible *", |
| 47 | Reason => "Needed for older compiler versions"); |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 48 | use type HW.Pos32; |
| Nico Huber | 31a5217 | 2017-03-05 14:17:34 +0100 | [diff] [blame] | 49 | pragma Warnings (GNAT, On, """Integer_32"" is already use-visible *"); |
| Nico Huber | 9e96a45 | 2019-09-22 20:25:17 +0200 | [diff] [blame] | 50 | |
| 51 | -- Validate just enough to satisfy Pipe_Setup pre conditions. |
| 52 | function Valid_FB |
| 53 | (FB : Framebuffer_Type; |
| 54 | Mode : Mode_Type) |
| 55 | return Boolean is |
| 56 | (Rotated_Width (FB) <= Mode.H_Visible and |
| 57 | Rotated_Height (FB) <= Mode.V_Visible and |
| 58 | (FB.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or |
| 59 | FB.Height + FB.Start_Y <= FB.V_Stride)); |
| 60 | |
| 61 | -- Also validate that we only use supported values / features. |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 62 | function Validate_Config |
| Nico Huber | f361ec8 | 2018-06-02 18:01:45 +0200 | [diff] [blame] | 63 | (FB : Framebuffer_Type; |
| 64 | Mode : Mode_Type; |
| Nico Huber | 9a4c4c3 | 2019-09-16 22:05:11 +0200 | [diff] [blame] | 65 | Pipe : Pipe_Index) |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 66 | return Boolean |
| 67 | with |
| Nico Huber | 9e96a45 | 2019-09-22 20:25:17 +0200 | [diff] [blame] | 68 | Post => (if Validate_Config'Result then Valid_FB (FB, Mode)); |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 69 | |
| Nico Huber | 88da05e | 2019-09-16 21:03:20 +0200 | [diff] [blame] | 70 | -- For still active pipes, ensure only timings |
| 71 | -- changed that don't affect FB validity. |
| 72 | function Stable_FB (Old_C, New_C : Pipe_Configs) return Boolean is |
| 73 | (for all P in Pipe_Index => |
| 74 | New_C (P).Port = Disabled or |
| 75 | (New_C (P).Port = Old_C (P).Port and |
| 76 | New_C (P).Framebuffer = Old_C (P).Framebuffer and |
| 77 | New_C (P).Cursor = Old_C (P).Cursor and |
| 78 | New_C (P).Mode.H_Visible = Old_C (P).Mode.H_Visible and |
| 79 | New_C (P).Mode.V_Visible = Old_C (P).Mode.V_Visible)); |
| 80 | |
| 81 | ---------------------------------------------------------------------------- |
| 82 | |
| 83 | function Highest_Dotclock (Configs : Pipe_Configs) return Frequency_Type; |
| 84 | |
| 85 | procedure Limit_Dotclocks |
| 86 | (Configs : in out Pipe_Configs; |
| 87 | Max : in Frequency_Type) |
| 88 | with |
| 89 | Post => Stable_FB (Configs'Old, Configs); |
| 90 | |
| Nico Huber | 8c45bcf | 2016-11-20 17:30:57 +0100 | [diff] [blame] | 91 | end HW.GFX.GMA.Config_Helpers; |