| Nico Huber | 83693c8 | 2016-10-08 22:17:55 +0200 | [diff] [blame] | 1 | -- |
| 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 |
| 6 | -- the Free Software Foundation; version 2 of the License. |
| 7 | -- |
| 8 | -- This program is distributed in the hope that it will be useful, |
| 9 | -- but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 | -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 11 | -- GNU General Public License for more details. |
| 12 | -- |
| 13 | |
| 14 | package HW.GFX.EDID |
| 15 | is |
| 16 | |
| 17 | use type Word8; |
| 18 | use type Word16; |
| 19 | |
| 20 | subtype Raw_EDID_Index is Natural range 0 .. 127; |
| 21 | subtype Raw_EDID_Data is Buffer (Raw_EDID_Index); |
| 22 | |
| 23 | function Valid (Raw_EDID : Raw_EDID_Data) return Boolean; |
| 24 | |
| 25 | DESCRIPTOR_1 : constant := 54; |
| 26 | |
| 27 | function Read_LE16 |
| 28 | (Raw_EDID : Raw_EDID_Data; |
| 29 | Offset : Raw_EDID_Index) |
| 30 | return Word16 |
| 31 | with |
| 32 | Pre => Offset < Raw_EDID_Index'Last; |
| 33 | |
| 34 | function Has_Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Boolean |
| 35 | with |
| 36 | Pre => Valid (Raw_EDID), |
| 37 | Post => |
| 38 | (Has_Preferred_Mode'Result = |
| 39 | (Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000 |
| 40 | in Frequency_Type and |
| 41 | ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or |
| 42 | (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and |
| 43 | ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or |
| 44 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and |
| 45 | ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or |
| 46 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and |
| 47 | ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or |
| 48 | (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and |
| 49 | ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or |
| 50 | (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and |
| 51 | ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or |
| 52 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and |
| 53 | ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or |
| 54 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and |
| 55 | ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or |
| 56 | (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0))); |
| 57 | function Preferred_Mode (Raw_EDID : Raw_EDID_Data) return Mode_Type |
| 58 | with |
| 59 | Pre => |
| 60 | Int64 (Read_LE16 (Raw_EDID, DESCRIPTOR_1)) * 10_000 |
| 61 | in Frequency_Type and |
| 62 | ( Raw_EDID (DESCRIPTOR_1 + 2) /= 0 or |
| 63 | (Raw_EDID (DESCRIPTOR_1 + 4) and 16#f0#) /= 0) and |
| 64 | ( Raw_EDID (DESCRIPTOR_1 + 8) /= 0 or |
| 65 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#c0#) /= 0) and |
| 66 | ( Raw_EDID (DESCRIPTOR_1 + 9) /= 0 or |
| 67 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#30#) /= 0) and |
| 68 | ( Raw_EDID (DESCRIPTOR_1 + 3) /= 0 or |
| 69 | (Raw_EDID (DESCRIPTOR_1 + 4) and 16#0f#) /= 0) and |
| 70 | ( Raw_EDID (DESCRIPTOR_1 + 5) /= 0 or |
| 71 | (Raw_EDID (DESCRIPTOR_1 + 7) and 16#f0#) /= 0) and |
| 72 | ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#f0#) /= 0 or |
| 73 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#0c#) /= 0) and |
| 74 | ((Raw_EDID (DESCRIPTOR_1 + 10) and 16#0f#) /= 0 or |
| 75 | (Raw_EDID (DESCRIPTOR_1 + 11) and 16#03#) /= 0) and |
| 76 | ( Raw_EDID (DESCRIPTOR_1 + 6) /= 0 or |
| 77 | (Raw_EDID (DESCRIPTOR_1 + 7) and 16#0f#) /= 0); |
| 78 | |
| 79 | end HW.GFX.EDID; |