graphics/fbcond: Make it robust against initial graphics driver being broken

This commit is contained in:
bjorn3
2025-03-15 17:30:39 +01:00
parent 87d71bc708
commit ffbfecbdb0
3 changed files with 9 additions and 22 deletions
+7 -21
View File
@@ -13,33 +13,19 @@ pub struct DisplayMap {
}
impl Display {
pub fn open_vt(vt: usize) -> io::Result<Self> {
let input_handle = ConsumerHandle::new_vt()?;
pub fn open_new_vt() -> io::Result<Self> {
let mut display = Self {
input_handle: ConsumerHandle::new_vt()?,
map: None,
};
if let Ok(display_handle) = Self::open_display(&input_handle) {
let map = display_handle
.map_display()
.unwrap_or_else(|e| panic!("failed to map display for VT #{vt}: {e}"));
display.reopen_for_handoff();
Ok(Self {
input_handle,
map: Some(DisplayMap {
display_handle,
inner: map,
}),
})
} else {
Ok(Self {
input_handle,
map: None,
})
}
Ok(display)
}
/// Re-open the display after a handoff.
pub fn reopen_for_handoff(&mut self) {
eprintln!("fbcond: Performing handoff");
let new_display_handle = Self::open_display(&self.input_handle).unwrap();
eprintln!("fbcond: Opened new display");
+1 -1
View File
@@ -43,7 +43,7 @@ impl FbconScheme {
let mut vts = BTreeMap::new();
for &vt_i in vt_ids {
let display = Display::open_vt(vt_i).expect("Failed to open display for vt");
let display = Display::open_new_vt().expect("Failed to open display for vt");
event_queue
.subscribe(
display.input_handle.event_handle().as_raw_fd() as usize,
+1
View File
@@ -23,6 +23,7 @@ impl TextScreen {
}
pub fn handle_handoff(&mut self) {
eprintln!("fbcond: Performing handoff");
self.display.reopen_for_handoff();
}