Skip to main content

VideoMode

Struct VideoMode 

Source
#[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
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§width: u16

Horizontal resolution in pixels.

§height: u16

Vertical resolution in pixels.

§refresh_rate: u16

Refresh rate in Hz.

§interlaced: bool

true for interlaced modes; false for progressive (the common case).

§h_front_porch: u16

Horizontal front porch in pixels (0 when not decoded from a DTD).

§h_sync_width: u16

Horizontal sync pulse width in pixels (0 when not decoded from a DTD).

§v_front_porch: u16

Vertical front porch in lines (0 when not decoded from a DTD).

§v_sync_width: u16

Vertical sync pulse width in lines (0 when not decoded from a DTD).

§h_border: u8

Horizontal border width in pixels on each side of the active area (0 when not from a DTD).

§v_border: u8

Vertical border height in lines on each side of the active area (0 when not from a DTD).

§stereo: StereoMode

Stereo 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

Source

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.

Source

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);
Source

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.

Source

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).

Trait Implementations§

Source§

impl Clone for VideoMode

Source§

fn clone(&self) -> VideoMode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for VideoMode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for VideoMode

Source§

fn default() -> VideoMode

Returns the “default value” for a type. Read more
Source§

impl PartialEq for VideoMode

Source§

fn eq(&self, other: &VideoMode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for VideoMode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> ExtensionData for T
where T: Any + Debug + Send + Sync,

Source§

fn as_any(&self) -> &(dyn Any + 'static)

Returns self as &dyn Any to enable downcasting.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.