Skip to content

Commit 80731d7

Browse files
committed
Take pixel format into account when determining best VESA mode
Prefer RGB or BGR modes over unknown ones.
1 parent a6d69e9 commit 80731d7

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

bios/common/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ pub enum PixelFormat {
4545
},
4646
}
4747

48+
impl PixelFormat {
49+
pub fn is_unknown(&self) -> bool {
50+
match self {
51+
PixelFormat::Rgb | PixelFormat::Bgr => false,
52+
PixelFormat::Unknown { .. } => true,
53+
}
54+
}
55+
}
56+
4857
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
4958
#[repr(C)]
5059
pub struct E820MemoryRegion {

bios/stage-2/src/vesa.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,16 @@ impl<'a> VesaInfo<'a> {
8383
continue;
8484
}
8585

86-
if best
87-
.as_ref()
88-
.map(|best| mode_info.width >= best.width || mode_info.height >= best.height)
89-
.unwrap_or(true)
90-
{
86+
let replace = match &best {
87+
None => true,
88+
Some(best) => {
89+
best.pixel_format.is_unknown()
90+
|| best.width < mode_info.width
91+
|| (best.width == mode_info.width && best.height < mode_info.height)
92+
}
93+
};
94+
95+
if replace {
9196
best = Some(mode_info);
9297
}
9398
}

0 commit comments

Comments
 (0)