LinuxKMS: Improve diagnostics when opening the linux framebuffer fails

Collect all the error messages and don't just print the last time. The
first one is most likely the interesting one.
This commit is contained in:
Simon Hausmann 2025-07-10 14:18:49 +00:00 committed by Simon Hausmann
parent 168c38899a
commit 0d8ecc6bc6
3 changed files with 9 additions and 5 deletions

View file

@ -131,6 +131,7 @@
"linebreak",
"lineedit",
"listview",
"LINUXFB",
"lvalue",
"microcontroller",
"microcontrollers",

View file

@ -163,7 +163,7 @@ udevadm trigger
## Legacy LinuxFB Interface
For software rendering, DRM dumb buffers are the preferred default way of posting framebuffers to the display. If DRM dumb buffers are not supported, the LinuxKMS backend falls back to using the Linux legacy
For software rendering, DRM dumb buffers are the preferred default way of posting frame buffers to the display. If DRM dumb buffers are not supported, the LinuxKMS backend falls back to using the Linux legacy
framebuffer interface (`/dev/fbX`).
To override this default and use only the legay framebuffer interface, set the `SLINT_BACKEND_LINUXFB=1` environment variable.
To override this default and use only the legacy framebuffer interface, set the `SLINT_BACKEND_LINUXFB=1` environment variable.

View file

@ -21,7 +21,7 @@ impl LinuxFBDisplay {
pub fn new(
device_opener: &crate::DeviceOpener,
) -> Result<Arc<dyn super::SoftwareBufferDisplay>, PlatformError> {
let mut last_err = None;
let mut fb_errors: Vec<String> = Vec::new();
for fbnum in 0..10 {
match Self::new_with_path(
@ -29,11 +29,14 @@ impl LinuxFBDisplay {
std::path::Path::new(&format!("/dev/fb{fbnum}")),
) {
Ok(dsp) => return Ok(dsp),
Err(e) => last_err = Some(e),
Err(e) => fb_errors.push(format!("Error using /dev/fb{fbnum}: {}", e)),
}
}
Err(last_err.unwrap_or_else(|| "Could not create a linuxfb display".into()))
Err(PlatformError::Other(format!(
"Could not open any legacy framebuffers.\n{}",
fb_errors.join("\n")
)))
}
fn new_with_path(