graphics/fbcond: Make it robust against initial graphics driver being broken
This commit is contained in:
@@ -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");
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -23,6 +23,7 @@ impl TextScreen {
|
||||
}
|
||||
|
||||
pub fn handle_handoff(&mut self) {
|
||||
eprintln!("fbcond: Performing handoff");
|
||||
self.display.reopen_for_handoff();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user