display_types/
resolved.rs1use crate::cea861::HdmiForumFrl;
4use crate::{ColorBitDepth, ColorFormat, VideoMode};
5
6#[non_exhaustive]
22#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
23#[derive(Debug, Clone, PartialEq)]
24pub struct ResolvedDisplayConfig {
25 pub mode: VideoMode,
27
28 pub color_encoding: ColorFormat,
30
31 pub bit_depth: ColorBitDepth,
33
34 pub frl_rate: HdmiForumFrl,
36
37 pub dsc_required: bool,
39
40 pub vrr_applicable: bool,
42}
43
44impl ResolvedDisplayConfig {
45 pub fn new(
47 mode: VideoMode,
48 color_encoding: ColorFormat,
49 bit_depth: ColorBitDepth,
50 frl_rate: HdmiForumFrl,
51 dsc_required: bool,
52 vrr_applicable: bool,
53 ) -> Self {
54 Self {
55 mode,
56 color_encoding,
57 bit_depth,
58 frl_rate,
59 dsc_required,
60 vrr_applicable,
61 }
62 }
63}
64
65#[cfg(test)]
66mod tests {
67 use super::*;
68 use crate::{ColorBitDepth, ColorFormat, VideoMode};
69
70 #[test]
71 fn new_roundtrips_all_fields() {
72 let mode = VideoMode::new(3840, 2160, 60, false);
73 let cfg = ResolvedDisplayConfig::new(
74 mode.clone(),
75 ColorFormat::Rgb444,
76 ColorBitDepth::Depth10,
77 HdmiForumFrl::Rate10Gbps4Lanes,
78 true,
79 false,
80 );
81 assert_eq!(cfg.mode, mode);
82 assert_eq!(cfg.color_encoding, ColorFormat::Rgb444);
83 assert_eq!(cfg.bit_depth, ColorBitDepth::Depth10);
84 assert_eq!(cfg.frl_rate, HdmiForumFrl::Rate10Gbps4Lanes);
85 assert!(cfg.dsc_required);
86 assert!(!cfg.vrr_applicable);
87 }
88
89 #[test]
90 fn tmds_config_uses_not_supported_frl() {
91 let mode = VideoMode::new(1920, 1080, 60, false);
92 let cfg = ResolvedDisplayConfig::new(
93 mode,
94 ColorFormat::Rgb444,
95 ColorBitDepth::Depth8,
96 HdmiForumFrl::NotSupported,
97 false,
98 true,
99 );
100 assert_eq!(cfg.frl_rate, HdmiForumFrl::NotSupported);
101 assert!(cfg.vrr_applicable);
102 assert!(!cfg.dsc_required);
103 }
104}