drivers/graphics: Fix resizing text VTs

This fixes a regression introduced in a40be7b44
This commit is contained in:
bjorn3
2026-03-20 20:23:44 +01:00
parent eaa390156d
commit 781aa57e4a
3 changed files with 38 additions and 20 deletions
+19 -5
View File
@@ -6,7 +6,7 @@ use std::{cmp, io, mem, ptr};
use drm::buffer::{Buffer, DrmFourcc};
use drm::control::dumbbuffer::{DumbBuffer, DumbMapping};
use drm::control::{framebuffer, ClipRect, Device};
use drm::control::{connector, crtc, framebuffer, ClipRect, Device, Mode};
use graphics_ipc::V2GraphicsHandle;
use orbclient::FONT;
@@ -52,6 +52,8 @@ impl Damage {
pub struct V2DisplayMap {
pub display_handle: V2GraphicsHandle,
connector: connector::Handle,
crtc: crtc::Handle,
fb: framebuffer::Handle,
pub buffer: DumbBuffer,
mapping: DumbMapping<'static>,
@@ -87,6 +89,8 @@ impl V2DisplayMap {
Ok(Self {
display_handle,
connector,
crtc,
fb,
buffer,
mapping: map,
@@ -344,7 +348,7 @@ impl TextScreen {
damage
}
pub fn resize(&mut self, map: &mut V2DisplayMap, width: u32, height: u32) -> io::Result<()> {
pub fn resize(&mut self, map: &mut V2DisplayMap, mode: Mode) -> io::Result<()> {
// FIXME fold row when target is narrower and maybe unfold when it is wider
fn copy_row(
old_map: &mut DisplayMap,
@@ -361,9 +365,11 @@ impl TextScreen {
}
}
let mut new_buffer =
map.display_handle
.create_dumb_buffer((width, height), DrmFourcc::Argb8888, 32)?;
let mut new_buffer = map.display_handle.create_dumb_buffer(
(u32::from(mode.size().0), u32::from(mode.size().1)),
DrmFourcc::Argb8888,
32,
)?;
let new_fb = map.display_handle.add_framebuffer(&new_buffer, 24, 32)?;
let new_mapping = map.display_handle.map_dumb_buffer(&mut new_buffer)?;
@@ -403,6 +409,14 @@ impl TextScreen {
let old_fb = mem::replace(&mut map.fb, new_fb);
map.mapping = new_mapping;
map.display_handle.set_crtc(
map.crtc,
Some(map.fb),
(0, 0),
&[map.connector],
Some(mode),
)?;
let _ = map.display_handle.destroy_dumb_buffer(old_buffer);
let _ = map.display_handle.destroy_framebuffer(old_fb);
+9 -7
View File
@@ -143,18 +143,20 @@ impl FbbootlogScheme {
}
fn handle_resize(map: &mut V2DisplayMap, text_screen: &mut TextScreen) {
let (width, height) = match map.display_handle.first_display().and_then(|handle| {
Ok(map.display_handle.get_connector(handle, true)?.modes()[0].size())
}) {
Ok((width, height)) => (width.into(), height.into()),
let mode = match map
.display_handle
.first_display()
.and_then(|handle| Ok(map.display_handle.get_connector(handle, true)?.modes()[0]))
{
Ok(mode) => mode,
Err(err) => {
eprintln!("fbbootlogd: failed to get display size: {}", err);
map.buffer.size()
return;
}
};
if (width, height) != map.buffer.size() {
match text_screen.resize(map, width, height) {
if (u32::from(mode.size().0), u32::from(mode.size().1)) != map.buffer.size() {
match text_screen.resize(map, mode) {
Ok(()) => eprintln!("fbbootlogd: mapped display"),
Err(err) => {
eprintln!("fbbootlogd: failed to create or map framebuffer: {}", err);
+10 -8
View File
@@ -52,18 +52,20 @@ impl Display {
}
pub fn handle_resize(map: &mut V2DisplayMap, text_screen: &mut TextScreen) {
let (width, height) = match map.display_handle.first_display().and_then(|handle| {
Ok(map.display_handle.get_connector(handle, true)?.modes()[0].size())
}) {
Ok((width, height)) => (width.into(), height.into()),
let mode = match map
.display_handle
.first_display()
.and_then(|handle| Ok(map.display_handle.get_connector(handle, true)?.modes()[0]))
{
Ok(mode) => mode,
Err(err) => {
log::error!("fbcond: failed to get display size: {}", err);
map.buffer.size()
eprintln!("fbbootlogd: failed to get display size: {}", err);
return;
}
};
if (width, height) != map.buffer.size() {
match text_screen.resize(map, width, height) {
if (u32::from(mode.size().0), u32::from(mode.size().1)) != map.buffer.size() {
match text_screen.resize(map, mode) {
Ok(()) => eprintln!("fbcond: mapped display"),
Err(err) => {
eprintln!("fbcond: failed to create or map framebuffer: {}", err);