mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-25 23:01:02 +00:00
fix(core): resolve crashes when running without display or with uninitialized display
[no changelog]
This commit is contained in:
parent
e6802bdd09
commit
0d3407b075
@ -55,7 +55,7 @@ pub fn refresh() {
|
||||
}
|
||||
|
||||
#[cfg(feature = "framebuffer")]
|
||||
pub fn get_frame_buffer() -> (&'static mut [u8], usize) {
|
||||
pub fn get_frame_buffer() -> Option<(&'static mut [u8], usize)> {
|
||||
let mut fb_info = ffi::display_fb_info_t {
|
||||
ptr: ptr::null_mut(),
|
||||
stride: 0,
|
||||
@ -63,6 +63,10 @@ pub fn get_frame_buffer() -> (&'static mut [u8], usize) {
|
||||
|
||||
unsafe { ffi::display_get_frame_buffer(&mut fb_info) };
|
||||
|
||||
if fb_info.ptr.is_null() {
|
||||
return None;
|
||||
}
|
||||
|
||||
let fb = unsafe {
|
||||
core::slice::from_raw_parts_mut(
|
||||
fb_info.ptr as *mut u8,
|
||||
@ -70,5 +74,5 @@ pub fn get_frame_buffer() -> (&'static mut [u8], usize) {
|
||||
)
|
||||
};
|
||||
|
||||
(fb, fb_info.stride)
|
||||
Some((fb, fb_info.stride))
|
||||
}
|
||||
|
@ -39,7 +39,13 @@ where
|
||||
|
||||
let cache = DrawingCache::new(bump, bump);
|
||||
|
||||
let (fb, fb_stride) = display::get_frame_buffer();
|
||||
let fb_info = display::get_frame_buffer();
|
||||
|
||||
if fb_info.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
let (fb, fb_stride) = fb_info.unwrap();
|
||||
|
||||
let mut canvas = unwrap!(Mono8Canvas::new(
|
||||
Offset::new(width, height),
|
||||
|
@ -32,7 +32,13 @@ where
|
||||
|
||||
let cache = DrawingCache::new(bump_a, bump_b);
|
||||
|
||||
let (fb, fb_stride) = display::get_frame_buffer();
|
||||
let fb_info = display::get_frame_buffer();
|
||||
|
||||
if fb_info.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
let (fb, fb_stride) = fb_info.unwrap();
|
||||
|
||||
let mut canvas = unwrap!(Rgb565Canvas::new(
|
||||
Offset::new(width, height),
|
||||
|
@ -32,7 +32,13 @@ where
|
||||
|
||||
let cache = DrawingCache::new(bump_a, bump_b);
|
||||
|
||||
let (fb, fb_stride) = display::get_frame_buffer();
|
||||
let fb_info = display::get_frame_buffer();
|
||||
|
||||
if fb_info.is_none() {
|
||||
return;
|
||||
}
|
||||
|
||||
let (fb, fb_stride) = fb_info.unwrap();
|
||||
|
||||
let mut canvas = unwrap!(Rgba8888Canvas::new(
|
||||
Offset::new(width, height),
|
||||
|
Loading…
Reference in New Issue
Block a user