|
|
99364f |
From a239886e159e6609c3e298effbd0243af8d0e333 Mon Sep 17 00:00:00 2001
|
|
|
99364f |
From: =?UTF-8?q?Jonas=20=C3=85dahl?= <jadahl@gmail.com>
|
|
|
99364f |
Date: Tue, 16 Jun 2020 11:30:11 +0200
|
|
|
99364f |
Subject: [PATCH 4/4] screen-cast: Disable DMA buffer based screen casting for
|
|
|
99364f |
QXL
|
|
|
99364f |
|
|
|
99364f |
QXL doesn't support mmap():ing a DMA buffer allocated in mutter inside
|
|
|
99364f |
the PipeWire stream consumer process. To make screen casting work again
|
|
|
99364f |
on QXL, disable DMA buffer based screen casting for QXL.
|
|
|
99364f |
|
|
|
99364f |
Eventually, it should be the client that renegotiates the supported
|
|
|
99364f |
buffer types, but until then we need this list.
|
|
|
99364f |
|
|
|
99364f |
https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1318
|
|
|
99364f |
---
|
|
|
99364f |
src/backends/meta-screen-cast.c | 11 ++++++
|
|
|
99364f |
src/backends/meta-screen-cast.h | 2 ++
|
|
|
99364f |
src/backends/native/meta-backend-native.c | 41 +++++++++++++++++++++++
|
|
|
99364f |
src/backends/native/meta-gpu-kms.c | 26 ++++++++++++++
|
|
|
99364f |
src/backends/native/meta-gpu-kms.h | 2 ++
|
|
|
99364f |
5 files changed, 82 insertions(+)
|
|
|
99364f |
|
|
|
99364f |
diff --git a/src/backends/meta-screen-cast.c b/src/backends/meta-screen-cast.c
|
|
|
99364f |
index 5f1ca8b5ca..268155e7b3 100644
|
|
|
99364f |
--- a/src/backends/meta-screen-cast.c
|
|
|
99364f |
+++ b/src/backends/meta-screen-cast.c
|
|
|
99364f |
@@ -46,6 +46,8 @@ struct _MetaScreenCast
|
|
|
99364f |
|
|
|
99364f |
MetaDbusSessionWatcher *session_watcher;
|
|
|
99364f |
MetaBackend *backend;
|
|
|
99364f |
+
|
|
|
99364f |
+ gboolean disable_dma_bufs;
|
|
|
99364f |
};
|
|
|
99364f |
|
|
|
99364f |
static void
|
|
|
99364f |
@@ -94,6 +96,12 @@ meta_screen_cast_get_backend (MetaScreenCast *screen_cast)
|
|
|
99364f |
return screen_cast->backend;
|
|
|
99364f |
}
|
|
|
99364f |
|
|
|
99364f |
+void
|
|
|
99364f |
+meta_screen_cast_disable_dma_bufs (MetaScreenCast *screen_cast)
|
|
|
99364f |
+{
|
|
|
99364f |
+ screen_cast->disable_dma_bufs = TRUE;
|
|
|
99364f |
+}
|
|
|
99364f |
+
|
|
|
99364f |
CoglDmaBufHandle *
|
|
|
99364f |
meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
|
|
99364f |
int width,
|
|
|
99364f |
@@ -107,6 +115,9 @@ meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
|
|
99364f |
g_autoptr (GError) error = NULL;
|
|
|
99364f |
CoglDmaBufHandle *dmabuf_handle;
|
|
|
99364f |
|
|
|
99364f |
+ if (screen_cast->disable_dma_bufs)
|
|
|
99364f |
+ return NULL;
|
|
|
99364f |
+
|
|
|
99364f |
dmabuf_handle = cogl_renderer_create_dma_buf (cogl_renderer,
|
|
|
99364f |
width, height,
|
|
|
99364f |
&error);
|
|
|
99364f |
diff --git a/src/backends/meta-screen-cast.h b/src/backends/meta-screen-cast.h
|
|
|
99364f |
index fb5a38f34f..fa54be729f 100644
|
|
|
99364f |
--- a/src/backends/meta-screen-cast.h
|
|
|
99364f |
+++ b/src/backends/meta-screen-cast.h
|
|
|
99364f |
@@ -50,6 +50,8 @@ GDBusConnection * meta_screen_cast_get_connection (MetaScreenCast *screen_cast);
|
|
|
99364f |
|
|
|
99364f |
MetaBackend * meta_screen_cast_get_backend (MetaScreenCast *screen_cast);
|
|
|
99364f |
|
|
|
99364f |
+void meta_screen_cast_disable_dma_bufs (MetaScreenCast *screen_cast);
|
|
|
99364f |
+
|
|
|
99364f |
CoglDmaBufHandle * meta_screen_cast_create_dma_buf_handle (MetaScreenCast *screen_cast,
|
|
|
99364f |
int width,
|
|
|
99364f |
int height);
|
|
|
99364f |
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
|
|
|
99364f |
index c473681cb0..2bf7f5e7e2 100644
|
|
|
99364f |
--- a/src/backends/native/meta-backend-native.c
|
|
|
99364f |
+++ b/src/backends/native/meta-backend-native.c
|
|
|
99364f |
@@ -57,6 +57,10 @@
|
|
|
99364f |
#include "core/meta-border.h"
|
|
|
99364f |
#include "meta/main.h"
|
|
|
99364f |
|
|
|
99364f |
+#ifdef HAVE_REMOTE_DESKTOP
|
|
|
99364f |
+#include "backends/meta-screen-cast.h"
|
|
|
99364f |
+#endif
|
|
|
99364f |
+
|
|
|
99364f |
struct _MetaBackendNative
|
|
|
99364f |
{
|
|
|
99364f |
MetaBackend parent;
|
|
|
99364f |
@@ -327,6 +331,39 @@ meta_backend_native_create_clutter_backend (MetaBackend *backend)
|
|
|
99364f |
return g_object_new (META_TYPE_CLUTTER_BACKEND_NATIVE, NULL);
|
|
|
99364f |
}
|
|
|
99364f |
|
|
|
99364f |
+#ifdef HAVE_REMOTE_DESKTOP
|
|
|
99364f |
+static void
|
|
|
99364f |
+maybe_disable_screen_cast_dma_bufs (MetaBackendNative *native)
|
|
|
99364f |
+{
|
|
|
99364f |
+ MetaBackend *backend = META_BACKEND (native);
|
|
|
99364f |
+ MetaRenderer *renderer = meta_backend_get_renderer (backend);
|
|
|
99364f |
+ MetaRendererNative *renderer_native = META_RENDERER_NATIVE (renderer);
|
|
|
99364f |
+ MetaGpuKms *primary_gpu;
|
|
|
99364f |
+ const char *driver_name;
|
|
|
99364f |
+ int i;
|
|
|
99364f |
+ static const char *disable_dma_buf_drivers[] = {
|
|
|
99364f |
+ "qxl",
|
|
|
99364f |
+ };
|
|
|
99364f |
+
|
|
|
99364f |
+ primary_gpu = meta_renderer_native_get_primary_gpu (renderer_native);
|
|
|
99364f |
+ driver_name = meta_gpu_kms_get_driver_name (primary_gpu);
|
|
|
99364f |
+
|
|
|
99364f |
+ for (i = 0; i < G_N_ELEMENTS (disable_dma_buf_drivers); i++)
|
|
|
99364f |
+ {
|
|
|
99364f |
+ if (g_strcmp0 (driver_name, disable_dma_buf_drivers[i]) == 0)
|
|
|
99364f |
+ {
|
|
|
99364f |
+ MetaScreenCast *screen_cast = meta_backend_get_screen_cast (backend);
|
|
|
99364f |
+
|
|
|
99364f |
+ g_message ("The '%s' driver doesn't support DMA buffer screen sharing, disabling.",
|
|
|
99364f |
+ driver_name);
|
|
|
99364f |
+
|
|
|
99364f |
+ meta_screen_cast_disable_dma_bufs (screen_cast);
|
|
|
99364f |
+ return;
|
|
|
99364f |
+ }
|
|
|
99364f |
+ }
|
|
|
99364f |
+}
|
|
|
99364f |
+#endif /* HAVE_REMOTE_DESKTOP */
|
|
|
99364f |
+
|
|
|
99364f |
static void
|
|
|
99364f |
meta_backend_native_post_init (MetaBackend *backend)
|
|
|
99364f |
{
|
|
|
99364f |
@@ -338,6 +375,10 @@ meta_backend_native_post_init (MetaBackend *backend)
|
|
|
99364f |
NULL, NULL);
|
|
|
99364f |
clutter_evdev_set_relative_motion_filter (manager, relative_motion_filter,
|
|
|
99364f |
meta_backend_get_monitor_manager (backend));
|
|
|
99364f |
+
|
|
|
99364f |
+#ifdef HAVE_REMOTE_DESKTOP
|
|
|
99364f |
+ maybe_disable_screen_cast_dma_bufs (META_BACKEND_NATIVE (backend));
|
|
|
99364f |
+#endif
|
|
|
99364f |
}
|
|
|
99364f |
|
|
|
99364f |
static MetaMonitorManager *
|
|
|
99364f |
diff --git a/src/backends/native/meta-gpu-kms.c b/src/backends/native/meta-gpu-kms.c
|
|
|
99364f |
index c569b948ef..93e509def5 100644
|
|
|
99364f |
--- a/src/backends/native/meta-gpu-kms.c
|
|
|
99364f |
+++ b/src/backends/native/meta-gpu-kms.c
|
|
|
99364f |
@@ -66,6 +66,8 @@ struct _MetaGpuKms
|
|
|
99364f |
char *file_path;
|
|
|
99364f |
GSource *source;
|
|
|
99364f |
|
|
|
99364f |
+ char *driver_name;
|
|
|
99364f |
+
|
|
|
99364f |
clockid_t clock_id;
|
|
|
99364f |
|
|
|
99364f |
drmModeConnector **connectors;
|
|
|
99364f |
@@ -790,6 +792,27 @@ init_outputs (MetaGpuKms *gpu_kms,
|
|
|
99364f |
setup_output_clones (gpu);
|
|
|
99364f |
}
|
|
|
99364f |
|
|
|
99364f |
+static void
|
|
|
99364f |
+init_info (MetaGpuKms *gpu_kms)
|
|
|
99364f |
+{
|
|
|
99364f |
+ drmVersion *drm_version;
|
|
|
99364f |
+
|
|
|
99364f |
+ drm_version = drmGetVersion (gpu_kms->fd);
|
|
|
99364f |
+ if (!drm_version)
|
|
|
99364f |
+ return;
|
|
|
99364f |
+
|
|
|
99364f |
+ gpu_kms->driver_name = g_strndup (drm_version->name,
|
|
|
99364f |
+ drm_version->name_len);
|
|
|
99364f |
+
|
|
|
99364f |
+ drmFreeVersion (drm_version);
|
|
|
99364f |
+}
|
|
|
99364f |
+
|
|
|
99364f |
+const char *
|
|
|
99364f |
+meta_gpu_kms_get_driver_name (MetaGpuKms *gpu_kms)
|
|
|
99364f |
+{
|
|
|
99364f |
+ return gpu_kms->driver_name;
|
|
|
99364f |
+}
|
|
|
99364f |
+
|
|
|
99364f |
static gboolean
|
|
|
99364f |
meta_kms_resources_init (MetaKmsResources *resources,
|
|
|
99364f |
int fd,
|
|
|
99364f |
@@ -865,6 +888,7 @@ meta_gpu_kms_read_current (MetaGpu *gpu,
|
|
|
99364f |
init_crtcs (gpu_kms, &resources);
|
|
|
99364f |
init_outputs (gpu_kms, &resources);
|
|
|
99364f |
init_frame_clock (gpu_kms);
|
|
|
99364f |
+ init_info (gpu_kms);
|
|
|
99364f |
|
|
|
99364f |
meta_kms_resources_release (&resources);
|
|
|
99364f |
|
|
|
99364f |
@@ -940,6 +964,8 @@ meta_gpu_kms_finalize (GObject *object)
|
|
|
99364f |
|
|
|
99364f |
free_resources (gpu_kms);
|
|
|
99364f |
|
|
|
99364f |
+ g_free (gpu_kms->driver_name);
|
|
|
99364f |
+
|
|
|
99364f |
G_OBJECT_CLASS (meta_gpu_kms_parent_class)->finalize (object);
|
|
|
99364f |
}
|
|
|
99364f |
|
|
|
99364f |
diff --git a/src/backends/native/meta-gpu-kms.h b/src/backends/native/meta-gpu-kms.h
|
|
|
99364f |
index 1f7a939e27..6096e58341 100644
|
|
|
99364f |
--- a/src/backends/native/meta-gpu-kms.h
|
|
|
99364f |
+++ b/src/backends/native/meta-gpu-kms.h
|
|
|
99364f |
@@ -108,4 +108,6 @@ MetaGpuKmsFlipClosureContainer * meta_gpu_kms_wrap_flip_closure (MetaGpuKms *gpu
|
|
|
99364f |
|
|
|
99364f |
void meta_gpu_kms_flip_closure_container_free (MetaGpuKmsFlipClosureContainer *closure_container);
|
|
|
99364f |
|
|
|
99364f |
+const char * meta_gpu_kms_get_driver_name (MetaGpuKms *gpu_kms);
|
|
|
99364f |
+
|
|
|
99364f |
#endif /* META_GPU_KMS_H */
|
|
|
99364f |
--
|
|
|
99364f |
2.26.2
|
|
|
99364f |
|