| 1 | const std = @import("../../../std.zig"); |
| 2 | const uefi = std.os.uefi; |
| 3 | const Guid = uefi.Guid; |
| 4 | const Handle = uefi.Handle; |
| 5 | const Status = uefi.Status; |
| 6 | const cc = uefi.cc; |
| 7 | |
| 8 | /// EDID information for an active video output device |
| 9 | pub const Active = extern struct { |
| 10 | size_of_edid: u32, |
| 11 | edid: ?[*]u8, |
| 12 | |
| 13 | pub const guid align(8) = Guid{ |
| 14 | .time_low = 0xbd8c1056, |
| 15 | .time_mid = 0x9f36, |
| 16 | .time_high_and_version = 0x44ec, |
| 17 | .clock_seq_high_and_reserved = 0x92, |
| 18 | .clock_seq_low = 0xa8, |
| 19 | .node = [_]u8{ 0xa6, 0x33, 0x7f, 0x81, 0x79, 0x86 }, |
| 20 | }; |
| 21 | }; |
| 22 | |
| 23 | /// EDID information for a video output device |
| 24 | pub const Discovered = extern struct { |
| 25 | size_of_edid: u32, |
| 26 | edid: ?[*]u8, |
| 27 | |
| 28 | pub const guid align(8) = Guid{ |
| 29 | .time_low = 0x1c0c34f6, |
| 30 | .time_mid = 0xd380, |
| 31 | .time_high_and_version = 0x41fa, |
| 32 | .clock_seq_high_and_reserved = 0xa0, |
| 33 | .clock_seq_low = 0x49, |
| 34 | .node = [_]u8{ 0x8a, 0xd0, 0x6c, 0x1a, 0x66, 0xaa }, |
| 35 | }; |
| 36 | }; |
| 37 | |
| 38 | /// Override EDID information |
| 39 | pub const Override = extern struct { |
| 40 | _get_edid: *const fn (*const Override, *const Handle, *Attributes, *usize, *?[*]u8) callconv(cc) Status, |
| 41 | |
| 42 | pub const GetEdidError = uefi.UnexpectedError || error{ |
| 43 | Unsupported, |
| 44 | }; |
| 45 | |
| 46 | /// Returns policy information and potentially a replacement EDID for the specified video output device. |
| 47 | pub fn getEdid(self: *const Override, handle: Handle) GetEdidError!Edid { |
| 48 | var size: usize = undefined; |
| 49 | var ptr: ?[*]u8 = undefined; |
| 50 | var attributes: Attributes = undefined; |
| 51 | switch (self._get_edid(self, &handle, &attributes, &size, &ptr)) { |
| 52 | .success => {}, |
| 53 | .unsupported => return error.Unsupported, |
| 54 | else => |status| return uefi.unexpectedStatus(status), |
| 55 | } |
| 56 | |
| 57 | return .{ |
| 58 | .attributes = attributes, |
| 59 | .edid = if (ptr) |p| p[0..size] else null, |
| 60 | }; |
| 61 | } |
| 62 | |
| 63 | pub const guid align(8) = Guid{ |
| 64 | .time_low = 0x48ecb431, |
| 65 | .time_mid = 0xfb72, |
| 66 | .time_high_and_version = 0x45c0, |
| 67 | .clock_seq_high_and_reserved = 0xa9, |
| 68 | .clock_seq_low = 0x22, |
| 69 | .node = [_]u8{ 0xf4, 0x58, 0xfe, 0x04, 0x0b, 0xd5 }, |
| 70 | }; |
| 71 | |
| 72 | pub const Edid = struct { |
| 73 | attributes: Attributes, |
| 74 | edid: ?[]u8, |
| 75 | }; |
| 76 | |
| 77 | pub const Attributes = packed struct(u32) { |
| 78 | dont_override: bool, |
| 79 | enable_hot_plug: bool, |
| 80 | _pad: u30 = 0, |
| 81 | }; |
| 82 | }; |