forge
Explore
Log in

Don't you dare go Hollow

backend: Use DeviceFd for GBM allocation

Browse files at this commit

c3fff2c654d7898297ecd79f5fb6fcdaaf9d3060Ivan MolodetskikhParent: bfb5dd5
DrmDeviceFd acquires master which won't work on winit. I don't think
it's needed on the GbmDevice type.
src/backend/mod.rsmodified+1 -2
@@ -173,8 +173,7 @@ impl Backend {
173173 #[cfg(feature = "xdp-gnome-screencast")]
174174 pub fn gbm_device(
175175 &self,
176- ) -> Option<smithay::backend::allocator::gbm::GbmDevice<smithay::backend::drm::DrmDeviceFd>>
177- {
176+ ) -> Option<smithay::backend::allocator::gbm::GbmDevice<smithay::utils::DeviceFd>> {
178177 match self {
179178 Backend::Tty(tty) => tty.primary_gbm_device(),
180179 Backend::Winit(_) => None,
src/backend/tty.rsmodified+12 -12
@@ -83,7 +83,7 @@ pub struct Tty {
8383 session: LibSeatSession,
8484 udev_dispatcher: Dispatcher<'static, UdevBackend, State>,
8585 libinput: Libinput,
86- gpu_manager: GpuManager<GbmGlesBackend<GlesRenderer, DrmDeviceFd>>,
86+ gpu_manager: GpuManager<GbmGlesBackend<GlesRenderer, DeviceFd>>,
8787 // DRM node corresponding to the primary GPU. May or may not be the same as
8888 // primary_render_node.
8989 primary_node: DrmNode,
@@ -106,8 +106,8 @@ pub struct Tty {
106106 pub type TtyRenderer<'render> = MultiRenderer<
107107 'render,
108108 'render,
109- GbmGlesBackend<GlesRenderer, DrmDeviceFd>,
110- GbmGlesBackend<GlesRenderer, DrmDeviceFd>,
109+ GbmGlesBackend<GlesRenderer, DeviceFd>,
110+ GbmGlesBackend<GlesRenderer, DeviceFd>,
111111 >;
112112
113113 pub type TtyFrame<'render, 'frame, 'buffer> = MultiFrame<
@@ -115,17 +115,17 @@ pub type TtyFrame<'render, 'frame, 'buffer> = MultiFrame<
115115 'render,
116116 'frame,
117117 'buffer,
118- GbmGlesBackend<GlesRenderer, DrmDeviceFd>,
119- GbmGlesBackend<GlesRenderer, DrmDeviceFd>,
118+ GbmGlesBackend<GlesRenderer, DeviceFd>,
119+ GbmGlesBackend<GlesRenderer, DeviceFd>,
120120 >;
121121
122122 pub type TtyRendererError<'render> = <TtyRenderer<'render> as RendererSuper>::Error;
123123
124124 type GbmDrmCompositor = DrmCompositor<
125- GbmAllocator<DrmDeviceFd>,
126- GbmFramebufferExporter<DrmDeviceFd>,
125+ GbmAllocator<DeviceFd>,
126+ GbmFramebufferExporter<DeviceFd>,
127127 (OutputPresentationFeedback, Duration),
128- DrmDeviceFd,
128+ DeviceFd,
129129 >;
130130
131131 pub struct OutputDevice {
@@ -138,9 +138,9 @@ pub struct OutputDevice {
138138 // SAFETY: drop after all the objects used with them are dropped.
139139 // See https://github.com/Smithay/smithay/issues/1102.
140140 drm: DrmDevice,
141- gbm: GbmDevice<DrmDeviceFd>,
141+ gbm: GbmDevice<DeviceFd>,
142142 // For display-only devices this will be the allocator from the primary device.
143- allocator: GbmAllocator<DrmDeviceFd>,
143+ allocator: GbmAllocator<DeviceFd>,
144144
145145 pub drm_lease_state: Option<DrmLeaseState>,
146146 non_desktop_connectors: HashSet<(connector::Handle, crtc::Handle)>,
@@ -780,7 +780,7 @@ impl Tty {
780780 }?;
781781 let gbm = {
782782 let _span = tracy_client::span!("GbmDevice::new");
783- GbmDevice::new(device_fd)
783+ GbmDevice::new(device_fd.device_fd())
784784 }?;
785785
786786 let mut try_initialize_gpu = || {
@@ -2253,7 +2253,7 @@ impl Tty {
22532253 }
22542254
22552255 #[cfg(feature = "xdp-gnome-screencast")]
2256- pub fn primary_gbm_device(&self) -> Option<GbmDevice<DrmDeviceFd>> {
2256+ pub fn primary_gbm_device(&self) -> Option<GbmDevice<DeviceFd>> {
22572257 // Try to find a device corresponding to the primary render node.
22582258 let device = self
22592259 .devices
src/screencasting/mod.rsmodified+2 -3
@@ -7,13 +7,12 @@ use anyhow::Context as _;
77 use calloop::LoopHandle;
88 use smithay::backend::allocator::format::FormatSet;
99 use smithay::backend::allocator::gbm::GbmDevice;
10-use smithay::backend::drm::DrmDeviceFd;
1110 use smithay::backend::renderer::element::utils::{Relocate, RelocateRenderElement};
1211 use smithay::backend::renderer::gles::GlesRenderer;
1312 use smithay::desktop::Window;
1413 use smithay::output::Output;
1514 use smithay::reexports::gbm::Modifier;
16-use smithay::utils::{Physical, Point, Scale, Size};
15+use smithay::utils::{DeviceFd, Physical, Point, Scale, Size};
1716 use zbus::object_server::SignalEmitter;
1817
1918 use crate::dbus::mutter_screen_cast::{self, CursorMode, ScreenCastToNiri, StreamTargetId};
@@ -77,7 +76,7 @@ impl Screencasting {
7776 }
7877
7978 impl State {
80- fn prepare_pw_cast(&mut self) -> anyhow::Result<Option<(GbmDevice<DrmDeviceFd>, FormatSet)>> {
79+ fn prepare_pw_cast(&mut self) -> anyhow::Result<Option<(GbmDevice<DeviceFd>, FormatSet)>> {
8180 // Ensure PipeWire is initialized.
8281 if self.niri.casting.pipewire.is_none() {
8382 let pw = PipeWire::new(
src/screencasting/pw_utils.rsmodified+6 -7
@@ -36,7 +36,6 @@ use smithay::backend::allocator::dmabuf::{AsDmabuf, Dmabuf};
3636 use smithay::backend::allocator::format::FormatSet;
3737 use smithay::backend::allocator::gbm::{GbmBuffer, GbmBufferFlags, GbmDevice};
3838 use smithay::backend::allocator::Fourcc;
39-use smithay::backend::drm::DrmDeviceFd;
4039 use smithay::backend::renderer::damage::OutputDamageTracker;
4140 use smithay::backend::renderer::element::utils::{Relocate, RelocateRenderElement};
4241 use smithay::backend::renderer::element::{Element, RenderElement, RenderElementStates};
@@ -52,7 +51,7 @@ use smithay::reexports::rustix::fs::{
5251 fcntl_add_seals, ftruncate, memfd_create, MemfdFlags, SealFlags,
5352 };
5453 use smithay::reexports::rustix::mm::{mmap, munmap, MapFlags, ProtFlags};
55-use smithay::utils::{Logical, Physical, Point, Scale, Size, Transform};
54+use smithay::utils::{DeviceFd, Logical, Physical, Point, Scale, Size, Transform};
5655 use zbus::object_server::SignalEmitter;
5756
5857 use crate::dbus::mutter_screen_cast::{self, CursorMode};
@@ -400,7 +399,7 @@ impl PipeWire {
400399 #[allow(clippy::too_many_arguments)]
401400 pub fn start_cast(
402401 &self,
403- gbm: Option<(GbmDevice<DrmDeviceFd>, FormatSet)>,
402+ gbm: Option<(GbmDevice<DeviceFd>, FormatSet)>,
404403 session_id: CastSessionId,
405404 stream_id: CastStreamId,
406405 target: CastTarget,
@@ -1390,7 +1389,7 @@ impl Cast {
13901389 impl CastInner {
13911390 unsafe fn on_add_buffer(
13921391 &mut self,
1393- gbm: Option<&GbmDevice<DrmDeviceFd>>,
1392+ gbm: Option<&GbmDevice<DeviceFd>>,
13941393 buffer: *mut pw_buffer,
13951394 ) -> anyhow::Result<bool> {
13961395 let CastState::Ready {
@@ -1553,7 +1552,7 @@ fn make_pod(buffer: &mut Vec<u8>, object: pod::Object) -> &Pod {
15531552 }
15541553
15551554 fn find_preferred_modifier(
1556- gbm: &GbmDevice<DrmDeviceFd>,
1555+ gbm: &GbmDevice<DeviceFd>,
15571556 size: Size<u32, Physical>,
15581557 fourcc: Fourcc,
15591558 modifiers: Vec<i64>,
@@ -1573,7 +1572,7 @@ fn find_preferred_modifier(
15731572 }
15741573
15751574 fn allocate_buffer(
1576- gbm: &GbmDevice<DrmDeviceFd>,
1575+ gbm: &GbmDevice<DeviceFd>,
15771576 size: Size<u32, Physical>,
15781577 fourcc: Fourcc,
15791578 modifiers: &[i64],
@@ -1605,7 +1604,7 @@ fn allocate_buffer(
16051604 }
16061605
16071606 fn allocate_dmabuf(
1608- gbm: &GbmDevice<DrmDeviceFd>,
1607+ gbm: &GbmDevice<DeviceFd>,
16091608 size: Size<u32, Physical>,
16101609 fourcc: Fourcc,
16111610 modifier: Modifier,