blob: 0d732304ade4a7c1035b7e7c3f54aa449ea78582 [file] [log] [blame]
Nico Huber83693c82016-10-08 22:17:55 +02001--
2-- Copyright (C) 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
15package HW.GFX.EDID
16is
17
18 use type Word8;
19 use type Word16;
20
21 subtype Raw_EDID_Index is Natural range 0 .. 127;
22 subtype Raw_EDID_Data is Buffer (Raw_EDID_Index);
23
24 function Valid (Raw_EDID : Raw_EDID_Data) return Boolean;
Nico Huber88a7f172016-11-18 21:19:46 +010025 procedure Sanitize (Raw_EDID : in out Raw_EDID_Data; Success : out Boolean)
26 with
27 Post => (if Success then Valid (Raw_EDID));
Nico Huber83693c82016-10-08 22:17:55 +020028
29 DESCRIPTOR_1 : constant := 54;
30
31 function Read_LE16
32 (Raw_EDID : Raw_EDID_Data;
33 Offset : Raw_EDID_Index)
34 return Word16
35 with
36 Pre => Offset < Raw_EDID_Index'Last;
37
Nico Huber393aa8a2016-10-21 14:18:53 +020038 function Compatible_Display
39 (Raw_EDID : Raw_EDID_Data;
40 Display : Display_Type)
41 return Boolean
42 with
43 Pre => Valid (Raw_EDID);
44
Nico Huber7eb13502018-06-04 14:42:13 +020045 function Has_Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Boolean is
46 (Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000 in Frequency_Type and
47 ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or
48 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and
49 ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or
50 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and
51 ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or
52 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and
53 ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or
54 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and
55 ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or
56 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and
57 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or
58 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and
59 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or
60 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and
61 ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or
62 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0))
Nico Huber83693c82016-10-08 22:17:55 +020063 with
Nico Huber7eb13502018-06-04 14:42:13 +020064 Pre => Valid (Raw_EDID);
Nico Huber83693c82016-10-08 22:17:55 +020065 function Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Mode_Type
66 with
Nico Huber7eb13502018-06-04 14:42:13 +020067 Pre => Valid (Raw_EDID) and then Has_Preferred_Mode (Raw_EDID);
Nico Huber83693c82016-10-08 22:17:55 +020068
69end HW.GFX.EDID;