driver/graphics/graphics-ipc: Remove most helpers for the v1 api

They aren't used within this repo and orbital has it's own copy of the
rest.
This commit is contained in:
bjorn3
2025-12-18 20:14:12 +01:00
parent 2422b3860c
commit 123fe53c5d
4 changed files with 3 additions and 121 deletions
+2 -1
View File
@@ -8,7 +8,8 @@ use std::mem;
use std::mem::transmute;
use std::sync::Arc;
use graphics_ipc::v1::{CursorDamage, Damage};
use graphics_ipc::v1::CursorDamage;
use graphics_ipc::v2::Damage;
use inputd::{VtEvent, VtEventKind};
use libredox::Fd;
use redox_scheme::scheme::SchemeSync;
@@ -30,46 +30,3 @@ impl Damage {
self
}
}
pub struct DisplayMap {
offscreen: *mut [u32],
width: usize,
height: usize,
}
impl DisplayMap {
pub(crate) unsafe fn new(offscreen: *mut [u32], width: usize, height: usize) -> Self {
DisplayMap {
offscreen,
width,
height,
}
}
pub fn ptr(&self) -> *const [u32] {
self.offscreen
}
pub fn ptr_mut(&mut self) -> *mut [u32] {
self.offscreen
}
pub fn width(&self) -> usize {
self.width
}
pub fn height(&self) -> usize {
self.height
}
}
unsafe impl Send for DisplayMap {}
unsafe impl Sync for DisplayMap {}
impl Drop for DisplayMap {
fn drop(&mut self) {
unsafe {
let _ = libredox::call::munmap(self.offscreen as *mut (), self.offscreen.len());
}
}
}
-76
View File
@@ -1,80 +1,4 @@
use std::fs::File;
use std::os::unix::io::AsRawFd;
use std::{io, mem, ptr, slice};
use libredox::flag;
pub use crate::common::Damage;
pub use crate::common::DisplayMap;
/// A graphics handle using the v1 graphics API.
///
/// The v1 graphics API only allows a single framebuffer for each VT, requires each display to be
/// handled separately and doesn't support page flipping.
///
/// This API is stable. No breaking changes are allowed to be made without a version bump.
pub struct V1GraphicsHandle {
file: File,
}
impl V1GraphicsHandle {
pub fn from_file(file: File) -> io::Result<Self> {
Ok(V1GraphicsHandle { file })
}
pub fn map_display(&self) -> io::Result<DisplayMap> {
let mut buf: [u8; 4096] = [0; 4096];
let count =
libredox::call::fpath(self.file.as_raw_fd() as usize, &mut buf).unwrap_or_else(|e| {
panic!("Could not read display path with fpath(): {e}");
});
let url =
String::from_utf8(Vec::from(&buf[..count])).expect("Could not create Utf8 Url String");
let path = url.split(':').nth(1).expect("Could not get path from url");
let mut path_parts = path.split('/').skip(1);
let width = path_parts
.next()
.unwrap_or("")
.parse::<usize>()
.unwrap_or(0);
let height = path_parts
.next()
.unwrap_or("")
.parse::<usize>()
.unwrap_or(0);
let display_ptr = unsafe {
libredox::call::mmap(libredox::call::MmapArgs {
fd: self.file.as_raw_fd() as usize,
offset: 0,
length: (width * height * 4),
prot: flag::PROT_READ | flag::PROT_WRITE,
flags: flag::MAP_SHARED,
addr: core::ptr::null_mut(),
})?
};
let offscreen = ptr::slice_from_raw_parts_mut(display_ptr as *mut u32, width * height);
Ok(unsafe { DisplayMap::new(offscreen, width, height) })
}
pub fn sync_full_screen(&self) -> io::Result<()> {
libredox::call::fsync(self.file.as_raw_fd() as usize)?;
Ok(())
}
pub fn sync_rect(&self, sync_rect: Damage) -> io::Result<()> {
libredox::call::write(self.file.as_raw_fd() as usize, unsafe {
slice::from_raw_parts(
ptr::addr_of!(sync_rect).cast::<u8>(),
mem::size_of::<Damage>(),
)
})?;
Ok(())
}
}
#[derive(Debug, Copy, Clone)]
#[repr(C, packed)]
+1 -1
View File
@@ -9,7 +9,7 @@ use drm::control::Device as _;
use drm::{ClientCapability, Device as _, DriverCapability};
use drm_fourcc::DrmFourcc;
pub use crate::common::{Damage, DisplayMap};
pub use crate::common::Damage;
extern "C" {
fn redox_sys_call_v0(