#[non_exhaustive]pub struct VideoMode {Show 14 fields
pub width: u16,
pub height: u16,
pub refresh_rate: u16,
pub interlaced: bool,
pub h_front_porch: u16,
pub h_sync_width: u16,
pub v_front_porch: u16,
pub v_sync_width: u16,
pub h_border: u8,
pub v_border: u8,
pub stereo: StereoMode,
pub sync: Option<SyncDefinition>,
pub pixel_clock_khz: Option<u32>,
pub source: Option<ModeSource>,
}Expand description
A display video mode expressed as resolution, refresh rate, and scan type.
Use VideoMode::new to construct a mode with only identity fields (the common case
for modes decoded from standard timing or SVD entries). Use
VideoMode::with_detailed_timing to add the blanking-interval and signal fields
available from a Detailed Timing Descriptor or equivalent.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.width: u16Horizontal resolution in pixels.
height: u16Vertical resolution in pixels.
refresh_rate: u16Refresh rate in Hz.
interlaced: booltrue for interlaced modes; false for progressive (the common case).
h_front_porch: u16Horizontal front porch in pixels (0 when not decoded from a DTD).
h_sync_width: u16Horizontal sync pulse width in pixels (0 when not decoded from a DTD).
v_front_porch: u16Vertical front porch in lines (0 when not decoded from a DTD).
v_sync_width: u16Vertical sync pulse width in lines (0 when not decoded from a DTD).
h_border: u8Horizontal border width in pixels on each side of the active area (0 when not from a DTD).
v_border: u8Vertical border height in lines on each side of the active area (0 when not from a DTD).
stereo: StereoModeStereo viewing support (default StereoMode::None for non-DTD modes).
sync: Option<SyncDefinition>Sync signal definition (None for non-DTD modes).
pixel_clock_khz: Option<u32>Pixel clock in kHz (None for modes not decoded from a Detailed Timing Descriptor).
source: Option<ModeSource>The source from which this mode was decoded, if known.
None for modes constructed directly via VideoMode::new without a table lookup.
Implementations§
Source§impl VideoMode
impl VideoMode
Sourcepub fn new(width: u16, height: u16, refresh_rate: u16, interlaced: bool) -> Self
pub fn new(width: u16, height: u16, refresh_rate: u16, interlaced: bool) -> Self
Constructs a VideoMode with the given identity fields.
All blanking-interval fields (h_front_porch, h_sync_width, v_front_porch,
v_sync_width, h_border, v_border) default to 0, stereo defaults to
StereoMode::None, and sync defaults to None. Use
with_detailed_timing to set those fields when
decoding from a Detailed Timing Descriptor.
Sourcepub fn with_pixel_clock(self, pixel_clock_khz: u32) -> Self
pub fn with_pixel_clock(self, pixel_clock_khz: u32) -> Self
Sets the exact pixel clock in kHz, returning the updated mode.
Use this when constructing a VideoMode from hardware timing registers or a
known-good mode table entry, where the exact pixel clock is available but full
Detailed Timing Descriptor fields are not. The supplied clock is returned verbatim
by pixel_clock_khz, bypassing the CVT-RB fallback
estimate.
use display_types::VideoMode;
use display_types::pixel_clock_khz;
// Custom panel: 1920×1200 @ 60 Hz, exact pixel clock from PLL register.
let mode = VideoMode::new(1920, 1200, 60, false).with_pixel_clock(154_000);
assert_eq!(pixel_clock_khz(&mode), 154_000);Sourcepub fn with_source(self, source: ModeSource) -> Self
pub fn with_source(self, source: ModeSource) -> Self
Sets the mode source, returning the updated mode.
Called automatically by vic_to_mode and
dmt_to_mode. Parsers decoding Detailed Timing
Descriptors should call .with_source(ModeSource::DtdIndex(n)) so that the
descriptor’s position survives into negotiated output.
Sourcepub fn with_detailed_timing(
self,
pixel_clock_khz: u32,
h_front_porch: u16,
h_sync_width: u16,
v_front_porch: u16,
v_sync_width: u16,
h_border: u8,
v_border: u8,
stereo: StereoMode,
sync: Option<SyncDefinition>,
) -> Self
pub fn with_detailed_timing( self, pixel_clock_khz: u32, h_front_porch: u16, h_sync_width: u16, v_front_porch: u16, v_sync_width: u16, h_border: u8, v_border: u8, stereo: StereoMode, sync: Option<SyncDefinition>, ) -> Self
Adds blanking-interval and signal fields decoded from a Detailed Timing Descriptor or equivalent source, returning the updated mode.
The 9-parameter count mirrors the DTD fields directly (EDID §3.10.3 / DisplayID §4.4).