mirror of
https://github.com/moonlight-stream/moonlight-qt.git
synced 2026-06-24 13:41:14 +00:00
Disable the DRM master hooks when EGLFS isn't used
This commit is contained in:
+16
-1
@@ -28,6 +28,9 @@
|
||||
#include <xf86drm.h>
|
||||
#include <xf86drmMode.h>
|
||||
|
||||
// Used to turn off the hooks when Qt is not using EGLFS
|
||||
bool g_DisableDrmHooks = false;
|
||||
|
||||
// We require SDL 2.0.15+ to hook because it supports sharing
|
||||
// the DRM FD with our code. This avoids having multiple DRM FDs
|
||||
// in flight at the same time which would significantly complicate
|
||||
@@ -90,6 +93,10 @@ int drmModeSetCrtc(int fd, uint32_t crtcId, uint32_t bufferId,
|
||||
// Lookup the real libdrm function pointers if we haven't yet
|
||||
pthread_once(&s_InitDrmFunctions, lookupRealDrmFunctions);
|
||||
|
||||
if (g_DisableDrmHooks) {
|
||||
return fn_drmModeSetCrtc(fd, crtcId, bufferId, x, y, connectors, count, mode);
|
||||
}
|
||||
|
||||
// Grab the first DRM Master FD that makes it in here. This will be the Qt
|
||||
// EGLFS backend's DRM FD, on which we will call drmDropMaster() later.
|
||||
if (g_QtDrmMasterFd == -1 && drmIsMaster(fd)) {
|
||||
@@ -128,7 +135,7 @@ int drmModePageFlip(int fd, uint32_t crtc_id, uint32_t fb_id, uint32_t flags, vo
|
||||
|
||||
// Call into the real thing
|
||||
int err = fn_drmModePageFlip(fd, crtc_id, fb_id, flags, user_data);
|
||||
if (err == -EACCES && fd == g_QtDrmMasterFd) {
|
||||
if (!g_DisableDrmHooks && err == -EACCES && fd == g_QtDrmMasterFd) {
|
||||
// If SDL took master from us, try to grab it back temporarily
|
||||
int oldMasterFd = takeMasterFromSdlFd();
|
||||
drmSetMaster(fd);
|
||||
@@ -148,6 +155,10 @@ int drmModeAtomicCommit(int fd, drmModeAtomicReqPtr req,
|
||||
// Lookup the real libdrm function pointers if we haven't yet
|
||||
pthread_once(&s_InitDrmFunctions, lookupRealDrmFunctions);
|
||||
|
||||
if (g_DisableDrmHooks) {
|
||||
return fn_drmModeAtomicCommit(fd, req, flags, user_data);
|
||||
}
|
||||
|
||||
// Grab the first DRM Master FD that makes it in here. This will be the Qt
|
||||
// EGLFS backend's DRM FD, on which we will call drmDropMaster() later.
|
||||
if (g_QtDrmMasterFd == -1 && drmIsMaster(fd)) {
|
||||
@@ -210,6 +221,10 @@ int close(int fd)
|
||||
// Lookup the real libc functions if we haven't yet
|
||||
pthread_once(&s_InitLibCFunctions, lookupRealLibCFunctions);
|
||||
|
||||
if (g_DisableDrmHooks) {
|
||||
return fn_close(fd);
|
||||
}
|
||||
|
||||
// Remove this entry from the SDL FD table
|
||||
bool lastSdlFd = removeSdlFd(fd);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user