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