diff --git a/drivers/graphics/driver-graphics/src/lib.rs b/drivers/graphics/driver-graphics/src/lib.rs index 538b82a257..2195b2a088 100644 --- a/drivers/graphics/driver-graphics/src/lib.rs +++ b/drivers/graphics/driver-graphics/src/lib.rs @@ -2,6 +2,7 @@ use std::collections::{BTreeMap, HashMap}; use std::ffi::c_char; +use std::fmt::Debug; use std::fs::File; use std::io::{self, Write}; use std::mem; @@ -22,8 +23,8 @@ use crate::objects::{DrmConnector, DrmObjectId, DrmObjects}; pub mod objects; -pub trait GraphicsAdapter: Sized { - type Connector; +pub trait GraphicsAdapter: Sized + Debug { + type Connector: Debug; type Framebuffer: Framebuffer; type Cursor: CursorFramebuffer; diff --git a/drivers/graphics/driver-graphics/src/objects.rs b/drivers/graphics/driver-graphics/src/objects.rs index 6efaae37b9..06f3029b52 100644 --- a/drivers/graphics/driver-graphics/src/objects.rs +++ b/drivers/graphics/driver-graphics/src/objects.rs @@ -5,6 +5,7 @@ use syscall::{Error, Result, EINVAL}; use crate::GraphicsAdapter; +#[derive(Debug)] pub struct DrmObjects { next_id: DrmObjectId, objects: HashMap>, @@ -122,22 +123,25 @@ impl DrmObjects { } } -#[derive(Copy, Clone, Eq, PartialEq, Hash)] +#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)] pub struct DrmObjectId(pub(crate) u32); impl DrmObjectId { pub const INVALID: DrmObjectId = DrmObjectId(0); } +#[derive(Debug)] struct DrmObject { kind: DrmObjectKind, } +#[derive(Debug)] enum DrmObjectKind { Connector(DrmConnector), Encoder(DrmEncoder), } +#[derive(Debug)] pub struct DrmConnector { pub modes: Vec, pub encoder_id: DrmObjectId, @@ -150,7 +154,7 @@ pub struct DrmConnector { pub driver_data: T::Connector, } -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] #[repr(u32)] pub enum DrmConnectorStatus { Disconnected = 0, @@ -158,7 +162,7 @@ pub enum DrmConnectorStatus { Unknown = 2, } -#[derive(Copy, Clone)] +#[derive(Debug, Copy, Clone)] #[repr(u32)] pub enum DrmSubpixelOrder { Unknown = 0, @@ -170,6 +174,7 @@ pub enum DrmSubpixelOrder { } // FIXME can we represent connector and encoder using a single struct? +#[derive(Debug)] pub struct DrmEncoder { pub crtc_id: DrmObjectId, pub possible_crtcs: u32, diff --git a/drivers/graphics/ihdgd/src/device/mod.rs b/drivers/graphics/ihdgd/src/device/mod.rs index 30082568c1..5a5dbb36dc 100644 --- a/drivers/graphics/ihdgd/src/device/mod.rs +++ b/drivers/graphics/ihdgd/src/device/mod.rs @@ -5,7 +5,7 @@ use common::{ use embedded_hal::prelude::*; use pcid_interface::{PciFunction, PciFunctionHandle}; use range_alloc::RangeAllocator; -use std::{collections::VecDeque, mem, sync::Arc, time::Duration}; +use std::{collections::VecDeque, fmt, mem, sync::Arc, time::Duration}; use syscall::error::{Error, Result, EIO, ENODEV, ERANGE}; mod aux; @@ -172,6 +172,19 @@ pub struct Device { transcoders: Vec, } +impl fmt::Debug for Device { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("Device") + .field("kind", &self.kind) + .field("alloc_buffers", &self.alloc_buffers) + .field("alloc_surfaces", &self.alloc_surfaces) + .field("gttmm", &self.gttmm) + .field("gm", &self.gm) + .field("ref_freq", &self.ref_freq) + .finish_non_exhaustive() + } +} + impl Device { pub fn new(pcid_handle: &mut PciFunctionHandle, func: &PciFunction) -> Result { let kind = match (func.full_device_id.vendor_id, func.full_device_id.device_id) { diff --git a/drivers/graphics/ihdgd/src/device/scheme.rs b/drivers/graphics/ihdgd/src/device/scheme.rs index 1c311cd48f..f6a286f856 100644 --- a/drivers/graphics/ihdgd/src/device/scheme.rs +++ b/drivers/graphics/ihdgd/src/device/scheme.rs @@ -14,6 +14,7 @@ use syscall::{error::EINVAL, PAGE_SIZE}; use super::Device; +#[derive(Debug)] pub struct Connector { framebuffer_id: usize, } diff --git a/drivers/graphics/vesad/src/scheme.rs b/drivers/graphics/vesad/src/scheme.rs index 98cd13a0b8..69d271047f 100644 --- a/drivers/graphics/vesad/src/scheme.rs +++ b/drivers/graphics/vesad/src/scheme.rs @@ -10,10 +10,12 @@ use graphics_ipc::v1::Damage; use graphics_ipc::v2::ipc::{DRM_CAP_DUMB_BUFFER, DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT}; use syscall::{EINVAL, PAGE_SIZE}; +#[derive(Debug)] pub struct FbAdapter { pub framebuffers: Vec, } +#[derive(Debug)] pub struct Connector { width: u32, height: u32, @@ -108,6 +110,7 @@ impl GraphicsAdapter for FbAdapter { } } +#[derive(Debug)] pub struct FrameBuffer { pub onscreen: *mut [u32], pub phys: usize, diff --git a/drivers/graphics/virtio-gpud/src/scheme.rs b/drivers/graphics/virtio-gpud/src/scheme.rs index 28a50ebcfe..5d5877a43f 100644 --- a/drivers/graphics/virtio-gpud/src/scheme.rs +++ b/drivers/graphics/virtio-gpud/src/scheme.rs @@ -1,3 +1,4 @@ +use std::fmt; use std::sync::Arc; use common::{dma::Dma, sgl}; @@ -27,6 +28,7 @@ impl Into for Damage { } } +#[derive(Debug)] pub struct VirtGpuConnector { display_id: u32, } @@ -88,6 +90,14 @@ pub struct VirtGpuAdapter<'a> { displays: Vec, } +impl<'a> fmt::Debug for VirtGpuAdapter<'a> { + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + f.debug_struct("VirtGpuAdapter") + .field("displays", &self.displays) + .finish_non_exhaustive() + } +} + impl VirtGpuAdapter<'_> { pub async fn update_displays(&mut self) -> Result<(), Error> { let display_info = self.get_display_info().await?;