Merge branch 'gpu_drm3' into 'main'
drivers/graphics/graphics-ipc: Use drm-sys for types and consts copied from DRM See merge request redox-os/base!64
This commit is contained in:
Generated
+18
@@ -577,6 +577,7 @@ name = "driver-graphics"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"common",
|
||||
"drm-sys",
|
||||
"graphics-ipc",
|
||||
"inputd",
|
||||
"libredox",
|
||||
@@ -595,6 +596,16 @@ dependencies = [
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "drm-sys"
|
||||
version = "0.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bafb66c8dbc944d69e15cfcc661df7e703beffbaec8bd63151368b06c5f9858c"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "e1000d"
|
||||
version = "0.1.0"
|
||||
@@ -855,6 +866,7 @@ name = "graphics-ipc"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"common",
|
||||
"drm-sys",
|
||||
"libredox",
|
||||
"log",
|
||||
]
|
||||
@@ -1088,6 +1100,12 @@ dependencies = [
|
||||
"redox_syscall",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.6.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a385b1be4e5c3e362ad2ffa73c392e53f031eaa5b7d648e64cd87f27f6063d7"
|
||||
|
||||
[[package]]
|
||||
name = "lived"
|
||||
version = "0.1.0"
|
||||
|
||||
@@ -4,6 +4,7 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
drm-sys = "0.8.0"
|
||||
log = "0.4"
|
||||
redox-scheme = "0.8.2"
|
||||
redox_syscall = "0.5"
|
||||
|
||||
@@ -22,8 +22,8 @@ pub trait GraphicsAdapter {
|
||||
fn name(&self) -> &'static [u8];
|
||||
fn desc(&self) -> &'static [u8];
|
||||
|
||||
fn get_cap(&self, cap: u64) -> Result<u64>;
|
||||
fn set_client_cap(&self, cap: u64, value: u64) -> Result<()>;
|
||||
fn get_cap(&self, cap: u32) -> Result<u64>;
|
||||
fn set_client_cap(&self, cap: u32, value: u64) -> Result<()>;
|
||||
|
||||
/// The maximum amount of displays that could be attached.
|
||||
///
|
||||
@@ -463,29 +463,40 @@ impl<T: GraphicsAdapter> SchemeSync for GraphicsScheme<T> {
|
||||
Ok(size_of::<ipc::Version>())
|
||||
}
|
||||
ipc::GET_CAP => {
|
||||
if payload.len() < size_of::<ipc::GetCap>() {
|
||||
if payload.len() < size_of::<drm_sys::drm_get_cap>() {
|
||||
return Err(Error::new(EINVAL));
|
||||
}
|
||||
let payload = unsafe {
|
||||
transmute::<&mut [u8; size_of::<ipc::GetCap>()], &mut ipc::GetCap>(
|
||||
transmute::<&mut [u8; size_of::<drm_sys::drm_get_cap>()], &mut drm_sys::drm_get_cap>(
|
||||
payload.as_mut_array().unwrap(),
|
||||
)
|
||||
};
|
||||
payload.value = self.adapter.get_cap(payload.capability)?;
|
||||
Ok(size_of::<ipc::GetCap>())
|
||||
payload.value = self.adapter.get_cap(
|
||||
payload
|
||||
.capability
|
||||
.try_into()
|
||||
.map_err(|_| syscall::Error::new(EINVAL))?,
|
||||
)?;
|
||||
Ok(size_of::<drm_sys::drm_get_cap>())
|
||||
}
|
||||
ipc::SET_CLIENT_CAP => {
|
||||
if payload.len() < size_of::<ipc::SetClientCap>() {
|
||||
if payload.len() < size_of::<drm_sys::drm_set_client_cap>() {
|
||||
return Err(Error::new(EINVAL));
|
||||
}
|
||||
let payload = unsafe {
|
||||
transmute::<&mut [u8; size_of::<ipc::SetClientCap>()], &mut ipc::SetClientCap>(
|
||||
payload.as_mut_array().unwrap(),
|
||||
)
|
||||
transmute::<
|
||||
&mut [u8; size_of::<drm_sys::drm_set_client_cap>()],
|
||||
&mut drm_sys::drm_set_client_cap,
|
||||
>(payload.as_mut_array().unwrap())
|
||||
};
|
||||
self.adapter
|
||||
.set_client_cap(payload.capability, payload.value)?;
|
||||
Ok(size_of::<ipc::SetClientCap>())
|
||||
self.adapter.set_client_cap(
|
||||
payload
|
||||
.capability
|
||||
.try_into()
|
||||
.map_err(|_| syscall::Error::new(EINVAL))?,
|
||||
payload.value,
|
||||
)?;
|
||||
Ok(size_of::<drm_sys::drm_set_client_cap>())
|
||||
}
|
||||
ipc::DISPLAY_COUNT => {
|
||||
if payload.len() < size_of::<ipc::DisplayCount>() {
|
||||
|
||||
@@ -4,6 +4,7 @@ version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
||||
drm-sys = "0.8.0"
|
||||
log = "0.4"
|
||||
libredox = "0.1.3"
|
||||
|
||||
|
||||
@@ -167,20 +167,10 @@ pub mod ipc {
|
||||
}
|
||||
|
||||
pub const GET_CAP: u64 = 0x0C;
|
||||
pub const CAP_DUMB_BUFFER: u64 = 0x1;
|
||||
#[repr(C, packed)]
|
||||
pub struct GetCap {
|
||||
pub capability: u64,
|
||||
pub value: u64,
|
||||
}
|
||||
pub use drm_sys::DRM_CAP_DUMB_BUFFER;
|
||||
|
||||
pub const SET_CLIENT_CAP: u64 = 0x0D;
|
||||
pub const CLIENT_CAP_CURSOR_PLANE_HOTSPOT: u64 = 6;
|
||||
#[repr(C, packed)]
|
||||
pub struct SetClientCap {
|
||||
pub capability: u64,
|
||||
pub value: u64,
|
||||
}
|
||||
pub use drm_sys::DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT;
|
||||
|
||||
// FIXME replace these with proper drm interfaces
|
||||
pub const DISPLAY_COUNT: u64 = 1;
|
||||
|
||||
@@ -4,7 +4,7 @@ use std::ptr::{self, NonNull};
|
||||
|
||||
use driver_graphics::{CursorFramebuffer, CursorPlane, Framebuffer, GraphicsAdapter};
|
||||
use graphics_ipc::v1::Damage;
|
||||
use graphics_ipc::v2::ipc::{CAP_DUMB_BUFFER, CLIENT_CAP_CURSOR_PLANE_HOTSPOT};
|
||||
use graphics_ipc::v2::ipc::{DRM_CAP_DUMB_BUFFER, DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT};
|
||||
use syscall::{EINVAL, PAGE_SIZE};
|
||||
|
||||
pub struct FbAdapter {
|
||||
@@ -27,16 +27,16 @@ impl GraphicsAdapter for FbAdapter {
|
||||
b"VESA"
|
||||
}
|
||||
|
||||
fn get_cap(&self, cap: u64) -> syscall::Result<u64> {
|
||||
fn get_cap(&self, cap: u32) -> syscall::Result<u64> {
|
||||
match cap {
|
||||
CAP_DUMB_BUFFER => Ok(1),
|
||||
DRM_CAP_DUMB_BUFFER => Ok(1),
|
||||
_ => Err(syscall::Error::new(EINVAL)),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_client_cap(&self, cap: u64, _value: u64) -> syscall::Result<()> {
|
||||
fn set_client_cap(&self, cap: u32, _value: u64) -> syscall::Result<()> {
|
||||
match cap {
|
||||
CLIENT_CAP_CURSOR_PLANE_HOTSPOT => Ok(()),
|
||||
DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT => Ok(()),
|
||||
_ => Err(syscall::Error::new(EINVAL)),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ use driver_graphics::{
|
||||
CursorFramebuffer, CursorPlane, Framebuffer, GraphicsAdapter, GraphicsScheme,
|
||||
};
|
||||
use graphics_ipc::v1::Damage;
|
||||
use graphics_ipc::v2::ipc::{CAP_DUMB_BUFFER, CLIENT_CAP_CURSOR_PLANE_HOTSPOT};
|
||||
use graphics_ipc::v2::ipc::{DRM_CAP_DUMB_BUFFER, DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT};
|
||||
use inputd::DisplayHandle;
|
||||
|
||||
use syscall::{EINVAL, PAGE_SIZE};
|
||||
@@ -209,17 +209,17 @@ impl<'a> GraphicsAdapter for VirtGpuAdapter<'a> {
|
||||
b"VirtIO GPU"
|
||||
}
|
||||
|
||||
fn get_cap(&self, cap: u64) -> syscall::Result<u64> {
|
||||
fn get_cap(&self, cap: u32) -> syscall::Result<u64> {
|
||||
match cap {
|
||||
CAP_DUMB_BUFFER => Ok(1),
|
||||
DRM_CAP_DUMB_BUFFER => Ok(1),
|
||||
_ => Err(syscall::Error::new(EINVAL)),
|
||||
}
|
||||
}
|
||||
|
||||
fn set_client_cap(&self, cap: u64, _value: u64) -> syscall::Result<()> {
|
||||
fn set_client_cap(&self, cap: u32, _value: u64) -> syscall::Result<()> {
|
||||
match cap {
|
||||
// FIXME hide cursor plane unless this client cap is set
|
||||
CLIENT_CAP_CURSOR_PLANE_HOTSPOT => Ok(()),
|
||||
DRM_CLIENT_CAP_CURSOR_PLANE_HOTSPOT => Ok(()),
|
||||
_ => Err(syscall::Error::new(EINVAL)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user