From 5c24276f40f22d1840eeeaf7a5a3b7772ae51449 Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Sun, 7 Jan 2024 18:46:53 -0800 Subject: [PATCH] WIP linux-dmabuf vesion 6 (target device) --- Cargo.toml | 9 +++++++++ src/wayland/dmabuf/dispatch.rs | 8 ++++++++ src/wayland/dmabuf/mod.rs | 22 +++++++++++++++++++--- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2764cc67ac83..d9e63162700d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -135,3 +135,12 @@ harness = false [profile.release-with-debug] inherits = "release" debug = true + +[patch.crates-io] +wayland-protocols = { git = "https://github.com/ids1024/wayland-rs", branch = "dmabuf-v6-wip" } +wayland-server = { git = "https://github.com/ids1024/wayland-rs", branch = "dmabuf-v6-wip" } +wayland-backend = { git = "https://github.com/ids1024/wayland-rs", branch = "dmabuf-v6-wip" } +wayland-sys = { git = "https://github.com/ids1024/wayland-rs", branch = "dmabuf-v6-wip" } +wayland-scanner = { git = "https://github.com/ids1024/wayland-rs", branch = "dmabuf-v6-wip" } +wayland-cursor = { git = "https://github.com/ids1024/wayland-rs", branch = "dmabuf-v6-wip" } +wayland-client = { git = "https://github.com/ids1024/wayland-rs", branch = "dmabuf-v6-wip" } diff --git a/src/wayland/dmabuf/dispatch.rs b/src/wayland/dmabuf/dispatch.rs index afa9230d2c22..03744fd8ef4a 100644 --- a/src/wayland/dmabuf/dispatch.rs +++ b/src/wayland/dmabuf/dispatch.rs @@ -74,6 +74,7 @@ where formats: data.formats.clone(), modifier: Mutex::new(None), planes: Mutex::new(Vec::with_capacity(MAX_PLANES)), + target_device: Mutex::new(None), }, ); } @@ -348,6 +349,13 @@ where } } + zwp_linux_buffer_params_v1::Request::SetTargetDevice { device } => { + if let Ok(bytes) = device.try_into() { + let dev = libc::dev_t::from_ne_bytes(bytes); + *data.target_device.lock().unwrap() = Some(dev); + } + } + _ => unreachable!(), } } diff --git a/src/wayland/dmabuf/mod.rs b/src/wayland/dmabuf/mod.rs index feeef28c4c2a..a1f35e2b093b 100644 --- a/src/wayland/dmabuf/mod.rs +++ b/src/wayland/dmabuf/mod.rs @@ -445,13 +445,19 @@ impl PartialEq for DmabufFeedback { impl DmabufFeedback { /// Send this feedback to the provided [`ZwpLinuxDmabufFeedbackV1`](zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1) pub fn send(&self, feedback: &zwp_linux_dmabuf_feedback_v1::ZwpLinuxDmabufFeedbackV1) { - feedback.main_device(self.0.main_device.to_ne_bytes().to_vec()); + if feedback.version() < 6 { + feedback.main_device(self.0.main_device.to_ne_bytes().to_vec()); + } feedback.format_table( self.0.format_table.file.as_fd(), self.0.format_table.file.size() as u32, ); for tranche in self.0.tranches.iter() { + let mut flags = tranche.flags; + if feedback.version() >= 6 && tranche.target_device == self.0.main_device { + flags |= zwp_linux_dmabuf_feedback_v1::TrancheFlags::Sampling; + } feedback.tranche_target_device(tranche.target_device.to_ne_bytes().to_vec()); feedback.tranche_flags(tranche.flags); feedback.tranche_formats( @@ -710,7 +716,7 @@ impl DmabufState { ); let formats = Arc::new(formats); - let version = if default_feedback.is_some() { 5 } else { 3 }; + let version = if default_feedback.is_some() { 6 } else { 3 }; let known_default_feedbacks = Arc::new(Mutex::new(Vec::new())); let default_feedback = default_feedback.map(|f| Arc::new(Mutex::new(f.clone()))); @@ -829,6 +835,8 @@ pub struct DmabufParamsData { /// Pending planes for the params. modifier: Mutex>, planes: Mutex>, + + target_device: Mutex>, } /// A handle to a registered dmabuf global. @@ -1206,7 +1214,15 @@ impl DmabufParamsData { } #[cfg(feature = "backend_drm")] - if let Some(node) = _node.and_then(|node| DrmNode::from_dev_id(node).ok()) { + if let Some(node) = self + .target_device + .lock() + .unwrap() + .clone() + .and_then(|node| DrmNode::from_dev_id(node).ok()) + { + buf.set_node(node); + } else if let Some(node) = _node.and_then(|node| DrmNode::from_dev_id(node).ok()) { buf.set_node(node); }