Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP linux-dmabuf vesion 6 (target device) #1273

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
8 changes: 8 additions & 0 deletions src/wayland/dmabuf/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
);
}
Expand Down Expand Up @@ -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!(),
}
}
Expand Down
22 changes: 19 additions & 3 deletions src/wayland/dmabuf/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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())));
Expand Down Expand Up @@ -829,6 +835,8 @@ pub struct DmabufParamsData {
/// Pending planes for the params.
modifier: Mutex<Option<Modifier>>,
planes: Mutex<Vec<Plane>>,

target_device: Mutex<Option<libc::dev_t>>,
}

/// A handle to a registered dmabuf global.
Expand Down Expand Up @@ -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);
}

Expand Down
Loading