blob: efc3b3630bdcd7ec7b271c12c81391b1705fb0e3 [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;
25
26 DESCRIPTOR_1 : constant := 54;
27
28 function Read_LE16
29 (Raw_EDID : Raw_EDID_Data;
30 Offset : Raw_EDID_Index)
31 return Word16
32 with
33 Pre => Offset < Raw_EDID_Index'Last;
34
35 function Has_Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Boolean
36 with
37 Pre => Valid (Raw_EDID),
38 Post =>
39 (Has_Preferred_Mode'Result =
40 (Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000
41 in Frequency_Type and
42 ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or
43 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and
44 ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or
45 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and
46 ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or
47 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and
48 ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or
49 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and
50 ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or
51 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and
52 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or
53 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and
54 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or
55 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and
56 ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or
57 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0)));
58 function Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Mode_Type
59 with
60 Pre =>
61 Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000
62 in Frequency_Type and
63 ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or
64 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and
65 ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or
66 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and
67 ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or
68 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and
69 ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or
70 (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and
71 ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or
72 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and
73 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or
74 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and
75 ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or
76 (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and
77 ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or
78 (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0);
79
80end HW.GFX.EDID;