From b28d2c2d803b06838dc7c40ca0e64c77efd23540 Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Mon, 16 Oct 2023 15:39:10 +0200 Subject: [PATCH] backends/drm: use closefb instead of removefb when available The closefb ioctl removes the userspace reference from the framebuffer but does not try to disable planes and outputs if the buffer is still used. This allows for example for smoother transitions between SDDM and the Plasma session --- src/backends/drm/drm_buffer.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/backends/drm/drm_buffer.cpp b/src/backends/drm/drm_buffer.cpp index ea097232a9..d0a4d1b86c 100644 --- a/src/backends/drm/drm_buffer.cpp +++ b/src/backends/drm/drm_buffer.cpp @@ -23,6 +23,10 @@ #include #include +#ifndef DRM_IOCTL_MODE_CLOSEFB +#define DRM_IOCTL_MODE_CLOSEFB 0xD0 +#endif + namespace KWin { @@ -43,7 +47,10 @@ DrmFramebuffer::DrmFramebuffer(DrmGpu *gpu, uint32_t fbId, GraphicsBuffer *buffe DrmFramebuffer::~DrmFramebuffer() { - drmModeRmFB(m_gpu->fd(), m_framebufferId); + uint32_t nonConstFb = m_framebufferId; + if (drmIoctl(m_gpu->fd(), DRM_IOCTL_MODE_CLOSEFB, &nonConstFb) != 0) { + drmIoctl(m_gpu->fd(), DRM_IOCTL_MODE_RMFB, &nonConstFb); + } } uint32_t DrmFramebuffer::framebufferId() const