1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
//! Basic display info.
use rust_decimal::Decimal;
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct BasicDisplayInfo {
pub input_definition: vsi::VideoSignalInterface,
/// The screen size or aspect ratio.
///
/// May not report any values if its a projector.
pub screen_size_or_aspect_ratio: Option<SizeOrRatio>,
/// The device's gamma value.
///
/// If `None`, it should be in an extension block.
pub reported_gamma: Option<Decimal>,
/// Info about the display's support for various misc. features.
pub feature_support: feature_support::FeatureSupport,
}
pub mod vsi {
/// Either an analog or digital VSI.
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum VideoSignalInterface {
// IMPLEMENTATION NOTE:
//
// if the first _BIT_ of the input is `0`, use Analog.
// else if `1`, it's Digital.
//
Analog {
signal_level_standard: analog::SignalLevelStandard,
video_setup: analog::VideoSetup,
sync_types: analog::SyncTypes,
/// Whether the display supports supports serration on the vertical sync.
serrations: bool,
},
Digital {
color_bit_depth: digital::ColorBitDepth,
supported_interface: Option<digital::SupportedVideoInterface>,
},
}
pub mod analog {
/// "Signal, Level, Total" for analog displays.
#[repr(C)]
#[expect(non_camel_case_types)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum SignalLevelStandard {
/// 0.7 + 0.3 = 1.0 V
_0700S_0300L_1000T,
/// 0.714 + 0.286 = 1.0 V
_0714S_0286L_1000T,
/// 1.0 + 0.4 = 1.4 V
_1000S_0400L_1400T,
/// 0.7 + 0.0 = 0.7 V
_0700S_0000L_0700T,
}
/// The type of video setup on an analog display.
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum VideoSetup {
BlackLevel,
B2BOrPedestal,
}
/// Info about the supported synchronization types.
///
/// `true` is supported, `false` is unsupported.
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct SyncTypes {
pub separate_sync_h_and_v: bool,
pub composite_sync_horizontal: bool,
pub composite_sync_green_video: bool,
}
}
pub mod digital {
/// The bit depth of a digital display.
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum ColorBitDepth {
/// The display didn't tell us!
Undefined,
D6Bits,
D8Bits,
D10Bits,
D12Bits,
D14Bits,
D16Bits,
/// unused as of v1.4
Reserved,
}
/// A supported digital video interface standard for a digital display.
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum SupportedVideoInterface {
Dvi,
HdmiA,
HdmiB,
Mddi,
DisplayPort,
}
}
}
/// The screen size or aspect ratio of a device, if given.
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum SizeOrRatio {
/// The screen size in centimeters (cm).
ScreenSize { horizontal_cm: u8, vertical_cm: u8 },
/// Just an aspect ratio.
AspectRatio { horizontal: u16, vertical: u16 },
}
pub mod feature_support {
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct FeatureSupport {
pub power_management: PowerManagement,
//
// IMPLEMENTATION NOTE: we get "color type" if VideoSignalInterface::Analog,
// otherwise we check for encoding formats
pub color_support: ColorSupport,
/// Whether sRGB Standard is the default color space.
pub srgb_std: bool,
/// Whether the Preferred Timing Mode has info about the native
/// pixel format and preferred refresh rate for the display.
pub says_pixel_format_and_refresh: bool,
/// Whether the display is continuous-frequency.
pub is_continuous_freq: bool,
}
/// Supported power modes.
///
/// Note that the modern standard, DPM, will just report Active Off as
/// supported and the others as unsupported.
///
/// `true` means supported; `false` indicates unsupported.
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub struct PowerManagement {
pub standby: bool,
pub suspend: bool,
pub active_off: bool,
}
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum ColorSupport {
Type(ColorType),
EncodingFormats(ColorEncodingFormats),
}
#[repr(C)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum ColorType {
MonochromeOrGrayscale,
RgbColor,
NonRgbColor,
Undefined,
}
#[repr(C)]
#[expect(non_camel_case_types)]
#[derive(Clone, Debug, PartialEq, PartialOrd)]
pub enum ColorEncodingFormats {
Rgb444,
Rgb444_YCrCb444,
Rgb444_YCrCb422,
Rgb444_YCrCb444_YCrCb422,
}
}