drivers/graphics: Slightly encapsulate V2DisplayMap

This commit is contained in:
bjorn3
2026-03-16 20:25:18 +01:00
parent 3903fe4f5a
commit f150813cfa
3 changed files with 23 additions and 27 deletions
+18 -4
View File
@@ -12,15 +12,24 @@ use orbclient::FONT;
pub struct V2DisplayMap {
pub display_handle: V2GraphicsHandle,
pub fb: framebuffer::Handle,
fb: framebuffer::Handle,
pub buffer: DumbBuffer,
mapping: DumbMapping<'static>,
}
impl V2DisplayMap {
pub fn new(display_handle: V2GraphicsHandle, width: u32, height: u32) -> io::Result<Self> {
let mut buffer =
display_handle.create_dumb_buffer((width, height), DrmFourcc::Argb8888, 32)?;
pub fn new(display_handle: V2GraphicsHandle) -> io::Result<Self> {
let connector = display_handle.first_display().unwrap();
let connector_info = display_handle.get_connector(connector, true).unwrap();
let mode = connector_info.modes()[0];
let (width, height) = mode.size();
let mut buffer = display_handle.create_dumb_buffer(
(width.into(), height.into()),
DrmFourcc::Argb8888,
32,
)?;
let fb = display_handle.add_framebuffer(&buffer, 32, 32)?;
let map = display_handle.map_dumb_buffer(&mut buffer)?;
@@ -44,6 +53,11 @@ impl V2DisplayMap {
height: self.buffer.size().1 as usize,
}
}
pub fn dirty_fb(&self, damage: Damage) -> io::Result<()> {
self.display_handle
.update_plane(0, u32::from(self.fb), damage)
}
}
struct DisplayMap {
+3 -13
View File
@@ -48,13 +48,7 @@ impl FbbootlogScheme {
}
};
let (width, height) = new_display_handle
.get_connector(new_display_handle.first_display().unwrap(), true)
.unwrap()
.modes()[0]
.size();
match V2DisplayMap::new(new_display_handle, width.into(), height.into()) {
match V2DisplayMap::new(new_display_handle) {
Ok(display_map) => self.display_map = Some(display_map),
Err(err) => {
eprintln!("fbbootlogd: failed to open display: {}", err);
@@ -145,9 +139,7 @@ impl FbbootlogScheme {
total_damage = total_damage.merge(damage);
}
}
map.display_handle
.update_plane(0, u32::from(map.fb), total_damage)
.unwrap();
map.dirty_fb(total_damage).unwrap();
}
fn handle_resize(map: &mut V2DisplayMap, text_screen: &mut TextScreen) {
@@ -247,9 +239,7 @@ impl SchemeSync for FbbootlogScheme {
let damage = self.text_screen.write(map, buf, &mut VecDeque::new());
if let Some(map) = &self.display_map {
map.display_handle
.update_plane(0, u32::from(map.fb), damage)
.unwrap();
map.dirty_fb(damage).unwrap();
}
}
}
+2 -10
View File
@@ -35,13 +35,7 @@ impl Display {
log::debug!("fbcond: Opened new display");
let (width, height) = new_display_handle
.get_connector(new_display_handle.first_display().unwrap(), true)
.unwrap()
.modes()[0]
.size();
match V2DisplayMap::new(new_display_handle, width.into(), height.into()) {
match V2DisplayMap::new(new_display_handle) {
Ok(map) => {
log::debug!(
"fbcond: Mapped new display with size {}x{}",
@@ -81,9 +75,7 @@ impl Display {
pub fn sync_rect(&mut self, damage: Damage) {
if let Some(map) = &self.map {
map.display_handle
.update_plane(0, u32::from(map.fb), damage)
.unwrap();
map.dirty_fb(damage).unwrap();
}
}
}