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