From cdb4ec45754885aedc66f457c23004e7d0fb9914 Mon Sep 17 00:00:00 2001 From: bjorn3 <17426603+bjorn3@users.noreply.github.com> Date: Tue, 17 Mar 2026 20:26:18 +0100 Subject: [PATCH] drivers/graphics: Remove unnecessary graphic-ipc dependencies And other unnecessary dependencies. Also move all graphics-ipc contents to the top of the crate. --- Cargo.lock | 10 +---- drivers/graphics/console-draw/src/lib.rs | 2 +- drivers/graphics/driver-graphics/Cargo.toml | 2 +- drivers/graphics/driver-graphics/src/lib.rs | 2 +- drivers/graphics/fbbootlogd/src/scheme.rs | 2 +- drivers/graphics/fbcond/src/display.rs | 2 +- drivers/graphics/graphics-ipc/Cargo.toml | 6 --- drivers/graphics/graphics-ipc/src/lib.rs | 43 ++++++++++++++++++- drivers/graphics/graphics-ipc/src/v2.rs | 46 --------------------- drivers/graphics/ihdgd/Cargo.toml | 1 - drivers/graphics/ihdgd/src/device/scheme.rs | 5 ++- drivers/graphics/vesad/Cargo.toml | 1 - drivers/graphics/vesad/src/scheme.rs | 5 ++- drivers/graphics/virtio-gpud/Cargo.toml | 1 - drivers/graphics/virtio-gpud/src/scheme.rs | 6 ++- 15 files changed, 58 insertions(+), 76 deletions(-) delete mode 100644 drivers/graphics/graphics-ipc/src/v2.rs diff --git a/Cargo.lock b/Cargo.lock index 35f19cf804..8ae50305d6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -593,10 +593,10 @@ dependencies = [ "common", "drm-sys", "edid", - "graphics-ipc", "inputd", "libredox", "log", + "redox-ioctl", "redox-scheme", "redox_syscall 0.7.3", ] @@ -932,12 +932,7 @@ dependencies = [ name = "graphics-ipc" version = "0.1.0" dependencies = [ - "common", "drm", - "libredox", - "log", - "plain", - "redox-ioctl", ] [[package]] @@ -1087,7 +1082,6 @@ dependencies = [ "drm-sys", "edid", "embedded-hal", - "graphics-ipc", "libredox", "log", "nb 1.1.0", @@ -2513,7 +2507,6 @@ dependencies = [ "daemon", "driver-graphics", "drm-sys", - "graphics-ipc", "libredox", "orbclient", "ransid", @@ -2568,7 +2561,6 @@ dependencies = [ "driver-graphics", "drm-sys", "futures", - "graphics-ipc", "libredox", "log", "orbclient", diff --git a/drivers/graphics/console-draw/src/lib.rs b/drivers/graphics/console-draw/src/lib.rs index eb7d217da6..6c0366c4b6 100644 --- a/drivers/graphics/console-draw/src/lib.rs +++ b/drivers/graphics/console-draw/src/lib.rs @@ -7,7 +7,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 graphics_ipc::v2::V2GraphicsHandle; +use graphics_ipc::V2GraphicsHandle; use orbclient::FONT; #[derive(Debug, Copy, Clone)] diff --git a/drivers/graphics/driver-graphics/Cargo.toml b/drivers/graphics/driver-graphics/Cargo.toml index ff70a9c8c5..a830c4f840 100644 --- a/drivers/graphics/driver-graphics/Cargo.toml +++ b/drivers/graphics/driver-graphics/Cargo.toml @@ -9,12 +9,12 @@ drm-sys.workspace = true #TODO: edid is abandoned, fork it an maintain? edid = "0.3.0" log.workspace = true +redox-ioctl.workspace = true redox-scheme.workspace = true redox_syscall.workspace = true libredox.workspace = true common = { path = "../../common" } -graphics-ipc = { path = "../graphics-ipc" } inputd = { path = "../../inputd" } [lints] diff --git a/drivers/graphics/driver-graphics/src/lib.rs b/drivers/graphics/driver-graphics/src/lib.rs index 6bd5966cf2..40d322431d 100644 --- a/drivers/graphics/driver-graphics/src/lib.rs +++ b/drivers/graphics/driver-graphics/src/lib.rs @@ -472,7 +472,7 @@ impl SchemeSync for GraphicsSchemeInner { metadata: &[u64], _ctx: &CallerCtx, ) -> Result { - use graphics_ipc::v2::ipc; + use redox_ioctl::drm as ipc; const DRM_FORMAT_ARGB8888: u32 = 0x34325241; // 'AR24' fourcc code, for ARGB8888 diff --git a/drivers/graphics/fbbootlogd/src/scheme.rs b/drivers/graphics/fbbootlogd/src/scheme.rs index ac9085d130..1d007bad29 100644 --- a/drivers/graphics/fbbootlogd/src/scheme.rs +++ b/drivers/graphics/fbbootlogd/src/scheme.rs @@ -4,7 +4,7 @@ use std::collections::VecDeque; use console_draw::{Damage, TextScreen, V2DisplayMap}; use drm::buffer::Buffer; use drm::control::Device; -use graphics_ipc::v2::V2GraphicsHandle; +use graphics_ipc::V2GraphicsHandle; use inputd::ConsumerHandle; use orbclient::{Event, EventOption}; use redox_scheme::scheme::SchemeSync; diff --git a/drivers/graphics/fbcond/src/display.rs b/drivers/graphics/fbcond/src/display.rs index eb323627b6..7e8a5b7571 100644 --- a/drivers/graphics/fbcond/src/display.rs +++ b/drivers/graphics/fbcond/src/display.rs @@ -1,7 +1,7 @@ use console_draw::{Damage, TextScreen, V2DisplayMap}; use drm::buffer::Buffer; use drm::control::Device; -use graphics_ipc::v2::V2GraphicsHandle; +use graphics_ipc::V2GraphicsHandle; use inputd::ConsumerHandle; use std::io; diff --git a/drivers/graphics/graphics-ipc/Cargo.toml b/drivers/graphics/graphics-ipc/Cargo.toml index cce499c77b..edeb40f80d 100644 --- a/drivers/graphics/graphics-ipc/Cargo.toml +++ b/drivers/graphics/graphics-ipc/Cargo.toml @@ -6,12 +6,6 @@ edition = "2021" [dependencies] drm.workspace = true -log.workspace = true -libredox.workspace = true -plain = "0.2" -redox-ioctl.workspace = true - -common = { path = "../../common" } [lints] workspace = true diff --git a/drivers/graphics/graphics-ipc/src/lib.rs b/drivers/graphics/graphics-ipc/src/lib.rs index 7083bd82d0..4dd3d2ffac 100644 --- a/drivers/graphics/graphics-ipc/src/lib.rs +++ b/drivers/graphics/graphics-ipc/src/lib.rs @@ -1 +1,42 @@ -pub mod v2; +use std::fs::File; +use std::io; +use std::os::fd::{AsFd, BorrowedFd}; + +use drm::control::connector::{self, State}; +use drm::control::Device as _; +use drm::{Device as _, DriverCapability}; + +/// A graphics handle using the v2 graphics API. +/// +/// The v2 graphics API allows creating framebuffers on the fly, using them for page flipping and +/// handles all displays using a single fd. This is basically a subset of the Linux DRM interface +/// with a couple of custom ioctls in the place of the KMS ioctls that are missing. +pub struct V2GraphicsHandle { + file: File, +} + +impl AsFd for V2GraphicsHandle { + fn as_fd(&self) -> BorrowedFd<'_> { + self.file.as_fd() + } +} + +impl drm::Device for V2GraphicsHandle {} +impl drm::control::Device for V2GraphicsHandle {} + +impl V2GraphicsHandle { + pub fn from_file(file: File) -> io::Result { + let handle = V2GraphicsHandle { file }; + assert!(handle.get_driver_capability(DriverCapability::DumbBuffer)? == 1); + Ok(handle) + } + + pub fn first_display(&self) -> io::Result { + for &connector in self.resource_handles().unwrap().connectors() { + if self.get_connector(connector, true)?.state() == State::Connected { + return Ok(connector); + } + } + Err(io::Error::other("no connected display")) + } +} diff --git a/drivers/graphics/graphics-ipc/src/v2.rs b/drivers/graphics/graphics-ipc/src/v2.rs deleted file mode 100644 index cf6ed3d3a6..0000000000 --- a/drivers/graphics/graphics-ipc/src/v2.rs +++ /dev/null @@ -1,46 +0,0 @@ -use std::fs::File; -use std::io; -use std::os::fd::{AsFd, BorrowedFd}; - -use drm::control::connector::{self, State}; -use drm::control::Device as _; -use drm::{Device as _, DriverCapability}; - -/// A graphics handle using the v2 graphics API. -/// -/// The v2 graphics API allows creating framebuffers on the fly, using them for page flipping and -/// handles all displays using a single fd. This is basically a subset of the Linux DRM interface -/// with a couple of custom ioctls in the place of the KMS ioctls that are missing. -pub struct V2GraphicsHandle { - file: File, -} - -impl AsFd for V2GraphicsHandle { - fn as_fd(&self) -> BorrowedFd<'_> { - self.file.as_fd() - } -} - -impl drm::Device for V2GraphicsHandle {} -impl drm::control::Device for V2GraphicsHandle {} - -impl V2GraphicsHandle { - pub fn from_file(file: File) -> io::Result { - let handle = V2GraphicsHandle { file }; - assert!(handle.get_driver_capability(DriverCapability::DumbBuffer)? == 1); - Ok(handle) - } - - pub fn first_display(&self) -> io::Result { - for &connector in self.resource_handles().unwrap().connectors() { - if self.get_connector(connector, true)?.state() == State::Connected { - return Ok(connector); - } - } - Err(io::Error::other("no connected display")) - } -} - -pub mod ipc { - pub use redox_ioctl::drm::*; -} diff --git a/drivers/graphics/ihdgd/Cargo.toml b/drivers/graphics/ihdgd/Cargo.toml index 6cfbd17000..7b9d5778d0 100644 --- a/drivers/graphics/ihdgd/Cargo.toml +++ b/drivers/graphics/ihdgd/Cargo.toml @@ -20,7 +20,6 @@ void = "1.0" common = { path = "../../common" } daemon = { path = "../../../daemon" } driver-graphics = { path = "../driver-graphics" } -graphics-ipc = { path = "../graphics-ipc" } pcid = { path = "../../pcid" } libredox.workspace = true diff --git a/drivers/graphics/ihdgd/src/device/scheme.rs b/drivers/graphics/ihdgd/src/device/scheme.rs index 5ddd72ad74..5dd093c421 100644 --- a/drivers/graphics/ihdgd/src/device/scheme.rs +++ b/drivers/graphics/ihdgd/src/device/scheme.rs @@ -9,8 +9,9 @@ use driver_graphics::kms::connector::KmsConnectorStatus; use driver_graphics::kms::objects::{self, KmsCrtc, KmsObjectId, KmsObjects}; use driver_graphics::kms::properties::DPMS; use driver_graphics::{Buffer, CursorPlane, Damage, GraphicsAdapter}; -use drm_sys::{drm_mode_modeinfo, DRM_MODE_DPMS_ON}; -use graphics_ipc::v2::ipc::{DRM_CAP_DUMB_BUFFER, DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT}; +use drm_sys::{ + drm_mode_modeinfo, DRM_CAP_DUMB_BUFFER, DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT, DRM_MODE_DPMS_ON, +}; use syscall::{error::EINVAL, PAGE_SIZE}; use super::Device; diff --git a/drivers/graphics/vesad/Cargo.toml b/drivers/graphics/vesad/Cargo.toml index 5c339e29d6..fe5fc64018 100644 --- a/drivers/graphics/vesad/Cargo.toml +++ b/drivers/graphics/vesad/Cargo.toml @@ -14,7 +14,6 @@ redox_event.workspace = true common = { path = "../../common" } daemon = { path = "../../../daemon" } driver-graphics = { path = "../driver-graphics" } -graphics-ipc = { path = "../graphics-ipc" } libredox.workspace = true [features] diff --git a/drivers/graphics/vesad/src/scheme.rs b/drivers/graphics/vesad/src/scheme.rs index eed74e1c54..d51ac723a8 100644 --- a/drivers/graphics/vesad/src/scheme.rs +++ b/drivers/graphics/vesad/src/scheme.rs @@ -7,8 +7,9 @@ use driver_graphics::kms::connector::KmsConnectorStatus; use driver_graphics::kms::objects::{self, KmsCrtc, KmsObjectId, KmsObjects}; use driver_graphics::kms::properties::DPMS; use driver_graphics::{Buffer, CursorPlane, Damage, GraphicsAdapter}; -use drm_sys::{drm_mode_modeinfo, DRM_MODE_DPMS_ON}; -use graphics_ipc::v2::ipc::{DRM_CAP_DUMB_BUFFER, DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT}; +use drm_sys::{ + drm_mode_modeinfo, DRM_CAP_DUMB_BUFFER, DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT, DRM_MODE_DPMS_ON, +}; use syscall::{EINVAL, PAGE_SIZE}; #[derive(Debug)] diff --git a/drivers/graphics/virtio-gpud/Cargo.toml b/drivers/graphics/virtio-gpud/Cargo.toml index 4359756f1f..cd015f7c86 100644 --- a/drivers/graphics/virtio-gpud/Cargo.toml +++ b/drivers/graphics/virtio-gpud/Cargo.toml @@ -15,7 +15,6 @@ anyhow.workspace = true common = { path = "../../common" } daemon = { path = "../../../daemon" } driver-graphics = { path = "../driver-graphics" } -graphics-ipc = { path = "../graphics-ipc" } virtio-core = { path = "../../virtio-core" } pcid = { path = "../../pcid" } diff --git a/drivers/graphics/virtio-gpud/src/scheme.rs b/drivers/graphics/virtio-gpud/src/scheme.rs index 4abeae0320..b550f060fa 100644 --- a/drivers/graphics/virtio-gpud/src/scheme.rs +++ b/drivers/graphics/virtio-gpud/src/scheme.rs @@ -6,8 +6,10 @@ use driver_graphics::kms::connector::KmsConnectorStatus; use driver_graphics::kms::objects::{self, KmsCrtc, KmsObjectId, KmsObjects}; use driver_graphics::kms::properties::{DPMS, EDID}; use driver_graphics::{Buffer as DrmBuffer, CursorPlane, Damage, GraphicsAdapter, GraphicsScheme}; -use drm_sys::{drm_mode_modeinfo, DRM_CAP_CURSOR_HEIGHT, DRM_CAP_CURSOR_WIDTH, DRM_MODE_DPMS_ON}; -use graphics_ipc::v2::ipc::{DRM_CAP_DUMB_BUFFER, DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT}; +use drm_sys::{ + drm_mode_modeinfo, DRM_CAP_CURSOR_HEIGHT, DRM_CAP_CURSOR_WIDTH, DRM_CAP_DUMB_BUFFER, + DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT, DRM_MODE_DPMS_ON, +}; use syscall::{EINVAL, PAGE_SIZE};