Skip to main content

liboptic_edid/structures/
basic_info.rs

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