blob: abbb2ee13c50fcb977c2ebaa007964918e834372 [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 Huber83693c82016-10-08 22:17:55 +020045 function Has_Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Boolean
46 with
47 Pre => Valid (Raw_EDID),
48 Post =>
49 (Has_Preferred_Mode'Result =
50 (Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000
51 in Frequency_Type and
52 ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or
53 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and
54 ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or
55 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and
56 ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or
57 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and
58 ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or
59 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and
60 ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or
61 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and
62 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or
63 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and
64 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or
65 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and
66 ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or
67 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0)));
68 function Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Mode_Type
69 with
70 Pre =>
71 Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000
72 in Frequency_Type and
73 ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or
74 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and
75 ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or
76 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and
77 ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or
78 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and
79 ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or
80 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and
81 ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or
82 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and
83 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or
84 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and
85 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or
86 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and
87 ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or
88 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0);
89
90end HW.GFX.EDID;