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