diff --git a/Cargo.lock b/Cargo.lock index 8ae50305d6..02b13447ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -591,6 +591,7 @@ name = "driver-graphics" version = "0.1.0" dependencies = [ "common", + "drm-fourcc", "drm-sys", "edid", "inputd", diff --git a/drivers/graphics/driver-graphics/Cargo.toml b/drivers/graphics/driver-graphics/Cargo.toml index a830c4f840..93422cefff 100644 --- a/drivers/graphics/driver-graphics/Cargo.toml +++ b/drivers/graphics/driver-graphics/Cargo.toml @@ -5,6 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] +drm-fourcc = "2.2.0" drm-sys.workspace = true #TODO: edid is abandoned, fork it an maintain? edid = "0.3.0" diff --git a/drivers/graphics/driver-graphics/src/lib.rs b/drivers/graphics/driver-graphics/src/lib.rs index 62bdaed27f..902144156e 100644 --- a/drivers/graphics/driver-graphics/src/lib.rs +++ b/drivers/graphics/driver-graphics/src/lib.rs @@ -9,6 +9,7 @@ use std::os::fd::BorrowedFd; use std::sync::{Arc, Mutex}; use std::{cmp, mem}; +use drm_fourcc::DrmFourcc; use drm_sys::{ drm_mode_modeinfo, drm_mode_property_enum, DRM_MODE_CURSOR_BO, DRM_MODE_CURSOR_MOVE, DRM_MODE_PROP_ATOMIC, DRM_MODE_PROP_BITMASK, DRM_MODE_PROP_BLOB, DRM_MODE_PROP_ENUM, @@ -447,8 +448,6 @@ impl SchemeSync for GraphicsSchemeInner { ) -> Result { use redox_ioctl::drm as ipc; - const DRM_FORMAT_ARGB8888: u32 = 0x34325241; // 'AR24' fourcc code, for ARGB8888 - fn id_index(id: u32) -> u32 { id & 0xFF } @@ -906,7 +905,7 @@ impl SchemeSync for GraphicsSchemeInner { data.set_crtc_id(crtc_id.0); data.set_fb_id(crtc.lock().unwrap().fb_id.0); data.set_possible_crtcs(1 << i); - data.set_format_type_ptr(&[DRM_FORMAT_ARGB8888]); + data.set_format_type_ptr(&[DrmFourcc::Argb8888 as u32]); Ok(0) }), ipc::MODE_OBJ_GET_PROPERTIES => { @@ -966,7 +965,7 @@ impl SchemeSync for GraphicsSchemeInner { data.set_width(fb.width); data.set_height(fb.height); - data.set_pixel_format(DRM_FORMAT_ARGB8888); + data.set_pixel_format(DrmFourcc::Argb8888 as u32); data.set_handles([*next_id, 0, 0, 0]); data.set_pitches([fb.width * 4, 0, 0, 0]); data.set_offsets([0; 4]);