Add linux-drm-syncobj-v1 protocol
This commit is contained in:
parent
005093b622
commit
9dddead15d
4 changed files with 73 additions and 1 deletions
|
|
@ -35,7 +35,11 @@ use smithay::{
|
||||||
wayland_server::{Client, DisplayHandle},
|
wayland_server::{Client, DisplayHandle},
|
||||||
},
|
},
|
||||||
utils::{Clock, DevPath, Monotonic, Size},
|
utils::{Clock, DevPath, Monotonic, Size},
|
||||||
wayland::{dmabuf::DmabufGlobal, relative_pointer::RelativePointerManagerState},
|
wayland::{
|
||||||
|
dmabuf::DmabufGlobal,
|
||||||
|
drm_syncobj::{supports_syncobj_eventfd, DrmSyncobjState},
|
||||||
|
relative_pointer::RelativePointerManagerState,
|
||||||
|
},
|
||||||
};
|
};
|
||||||
use surface::GbmDrmOutput;
|
use surface::GbmDrmOutput;
|
||||||
use tracing::{error, info, trace, warn};
|
use tracing::{error, info, trace, warn};
|
||||||
|
|
@ -70,6 +74,8 @@ pub struct KmsState {
|
||||||
|
|
||||||
session: LibSeatSession,
|
session: LibSeatSession,
|
||||||
libinput: Libinput,
|
libinput: Libinput,
|
||||||
|
|
||||||
|
pub syncobj_state: Option<DrmSyncobjState>,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn init_backend(
|
pub fn init_backend(
|
||||||
|
|
@ -136,6 +142,8 @@ pub fn init_backend(
|
||||||
|
|
||||||
session,
|
session,
|
||||||
libinput: libinput_context,
|
libinput: libinput_context,
|
||||||
|
|
||||||
|
syncobj_state: None,
|
||||||
});
|
});
|
||||||
|
|
||||||
// start x11
|
// start x11
|
||||||
|
|
@ -148,6 +156,23 @@ pub fn init_backend(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let kms = match &mut state.backend {
|
||||||
|
BackendData::Kms(kms) => kms,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
if let Some(primary_node) = kms
|
||||||
|
.primary_node
|
||||||
|
.and_then(|node| node.node_with_type(NodeType::Primary).and_then(|x| x.ok()))
|
||||||
|
{
|
||||||
|
if let Some(device) = kms.drm_devices.get(&primary_node) {
|
||||||
|
let import_device = device.drm.device().device_fd().clone();
|
||||||
|
if supports_syncobj_eventfd(&import_device) {
|
||||||
|
let syncobj_state = DrmSyncobjState::new::<State>(&dh, import_device);
|
||||||
|
kms.syncobj_state = Some(syncobj_state);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ use smithay::{
|
||||||
CompositorHandler, CompositorState, SurfaceAttributes,
|
CompositorHandler, CompositorState, SurfaceAttributes,
|
||||||
},
|
},
|
||||||
dmabuf::get_dmabuf,
|
dmabuf::get_dmabuf,
|
||||||
|
drm_syncobj::DrmSyncobjCachedState,
|
||||||
seat::WaylandFocus,
|
seat::WaylandFocus,
|
||||||
shell::{
|
shell::{
|
||||||
wlr_layer::LayerSurfaceAttributes,
|
wlr_layer::LayerSurfaceAttributes,
|
||||||
|
|
@ -100,7 +101,14 @@ impl CompositorHandler for State {
|
||||||
|
|
||||||
fn new_surface(&mut self, surface: &WlSurface) {
|
fn new_surface(&mut self, surface: &WlSurface) {
|
||||||
add_pre_commit_hook::<Self, _>(surface, move |state, _dh, surface| {
|
add_pre_commit_hook::<Self, _>(surface, move |state, _dh, surface| {
|
||||||
|
let mut acquire_point = None;
|
||||||
let maybe_dmabuf = with_states(surface, |surface_data| {
|
let maybe_dmabuf = with_states(surface, |surface_data| {
|
||||||
|
acquire_point = surface_data
|
||||||
|
.cached_state
|
||||||
|
.get::<DrmSyncobjCachedState>()
|
||||||
|
.pending()
|
||||||
|
.acquire_point
|
||||||
|
.clone();
|
||||||
surface_data
|
surface_data
|
||||||
.cached_state
|
.cached_state
|
||||||
.get::<SurfaceAttributes>()
|
.get::<SurfaceAttributes>()
|
||||||
|
|
@ -113,6 +121,25 @@ impl CompositorHandler for State {
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
if let Some(dmabuf) = maybe_dmabuf {
|
if let Some(dmabuf) = maybe_dmabuf {
|
||||||
|
if let Some(acquire_point) = acquire_point {
|
||||||
|
if let Ok((blocker, source)) = acquire_point.generate_blocker() {
|
||||||
|
let client = surface.client().unwrap();
|
||||||
|
let res = state.common.event_loop_handle.insert_source(
|
||||||
|
source,
|
||||||
|
move |_, _, state| {
|
||||||
|
let dh = state.common.display_handle.clone();
|
||||||
|
state
|
||||||
|
.client_compositor_state(&client)
|
||||||
|
.blocker_cleared(state, &dh);
|
||||||
|
Ok(())
|
||||||
|
},
|
||||||
|
);
|
||||||
|
if res.is_ok() {
|
||||||
|
add_blocker(surface, blocker);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
if let Ok((blocker, source)) = dmabuf.generate_blocker(Interest::READ) {
|
if let Ok((blocker, source)) = dmabuf.generate_blocker(Interest::READ) {
|
||||||
let client = surface.client().unwrap();
|
let client = surface.client().unwrap();
|
||||||
let res =
|
let res =
|
||||||
|
|
|
||||||
19
src/wayland/handlers/drm_syncobj.rs
Normal file
19
src/wayland/handlers/drm_syncobj.rs
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
// SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
use crate::state::{BackendData, State};
|
||||||
|
use smithay::{
|
||||||
|
delegate_drm_syncobj,
|
||||||
|
wayland::drm_syncobj::{DrmSyncobjHandler, DrmSyncobjState},
|
||||||
|
};
|
||||||
|
|
||||||
|
impl DrmSyncobjHandler for State {
|
||||||
|
fn drm_syncobj_state(&mut self) -> &mut DrmSyncobjState {
|
||||||
|
let kms = match &mut self.backend {
|
||||||
|
BackendData::Kms(kms) => kms,
|
||||||
|
_ => unreachable!(),
|
||||||
|
};
|
||||||
|
kms.syncobj_state.as_mut().unwrap()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
delegate_drm_syncobj!(State);
|
||||||
|
|
@ -10,6 +10,7 @@ pub mod decoration;
|
||||||
pub mod dmabuf;
|
pub mod dmabuf;
|
||||||
pub mod drm;
|
pub mod drm;
|
||||||
pub mod drm_lease;
|
pub mod drm_lease;
|
||||||
|
pub mod drm_syncobj;
|
||||||
pub mod foreign_toplevel_list;
|
pub mod foreign_toplevel_list;
|
||||||
pub mod fractional_scale;
|
pub mod fractional_scale;
|
||||||
pub mod idle_inhibit;
|
pub mod idle_inhibit;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue