kms: Add atomic MetaKmsImplDevice backend
This adds a MetaKmsImplDevice backend using atomic drmMode* API in constrast to non-atomic legacy drmMode* API used in MetaKmsImplDeviceSimple. This has various behavioral differences worth noting, compared to the simple backend: * We can only commit once per CRTC per page flip. This means that we can only update the cursor plane once. If a primary plane composition missed a dead line, we cannot commit only a cursor update that would be presented earlier. * Partial success is not possible with the atomic backend. Cursor planes may fail with the simple backend. This is not the case with the atomic backend. This will instead later be handled using API specific to the atomic backend, that will effectively translate into TEST_ONLY commits. For testing and debugging purposes, the environment variable MUTTER_DEBUG_ENABLE_ATOMIC_KMS can be set to either 1 or 0 to force-enable or force-disable atomic mode setting. Setting it to some other value will cause mutter to abort(). Closes: https://gitlab.gnome.org/GNOME/mutter/-/issues/548 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1488>
This commit is contained in:
@ -26,6 +26,7 @@
|
||||
#include <xf86drm.h>
|
||||
|
||||
#include "backends/native/meta-backend-native.h"
|
||||
#include "backends/native/meta-kms-impl-device-atomic.h"
|
||||
#include "backends/native/meta-kms-impl-device-simple.h"
|
||||
#include "backends/native/meta-kms-impl-device.h"
|
||||
#include "backends/native/meta-kms-impl.h"
|
||||
@ -237,6 +238,20 @@ typedef struct _CreateImplDeviceData
|
||||
char *out_driver_description;
|
||||
} CreateImplDeviceData;
|
||||
|
||||
static gboolean
|
||||
is_atomic_allowed (const char *driver_name)
|
||||
{
|
||||
const char *atomic_driver_deny_list[] = {
|
||||
"qxl",
|
||||
"vmwgfx",
|
||||
"vboxvideo",
|
||||
"nvidia-drm",
|
||||
NULL,
|
||||
};
|
||||
|
||||
return !g_strv_contains (atomic_driver_deny_list, driver_name);
|
||||
}
|
||||
|
||||
static gboolean
|
||||
get_driver_info (int fd,
|
||||
char **name,
|
||||
@ -264,9 +279,12 @@ meta_create_kms_impl_device (MetaKmsDevice *device,
|
||||
const char *path,
|
||||
GError **error)
|
||||
{
|
||||
GType impl_device_type;
|
||||
gboolean supports_atomic_mode_setting;
|
||||
int ret;
|
||||
g_autofree char *driver_name = NULL;
|
||||
g_autofree char *driver_description = NULL;
|
||||
const char *atomic_kms_enable_env;
|
||||
|
||||
meta_assert_in_kms_impl (meta_kms_impl_get_kms (impl));
|
||||
|
||||
@ -285,10 +303,64 @@ meta_create_kms_impl_device (MetaKmsDevice *device,
|
||||
driver_description = g_strdup ("Unknown");
|
||||
}
|
||||
|
||||
g_message ("Adding device '%s' (%s) using non-atomic mode setting.",
|
||||
path, driver_name);
|
||||
atomic_kms_enable_env = getenv ("MUTTER_DEBUG_ENABLE_ATOMIC_KMS");
|
||||
if (atomic_kms_enable_env)
|
||||
{
|
||||
if (g_strcmp0 (atomic_kms_enable_env, "1") == 0)
|
||||
{
|
||||
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_ATOMIC;
|
||||
if (drmSetClientCap (fd, DRM_CLIENT_CAP_ATOMIC, 1) != 0)
|
||||
{
|
||||
g_error ("Failed to force atomic mode setting on '%s' (%s).",
|
||||
path, driver_name);
|
||||
}
|
||||
}
|
||||
else if (g_strcmp0 (atomic_kms_enable_env, "0") == 0)
|
||||
{
|
||||
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_SIMPLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_error ("Invalid value '%s' for MUTTER_DEBUG_ENABLE_ATOMIC_KMS, "
|
||||
"bailing.",
|
||||
atomic_kms_enable_env);
|
||||
}
|
||||
|
||||
return g_initable_new (META_TYPE_KMS_IMPL_DEVICE_SIMPLE, NULL, error,
|
||||
g_message ("Mode setting implementation for '%s' (%s) forced (%s).",
|
||||
path, driver_name,
|
||||
impl_device_type == META_TYPE_KMS_IMPL_DEVICE_ATOMIC ?
|
||||
"atomic" : "non-atomic");
|
||||
}
|
||||
else if (!is_atomic_allowed (driver_name))
|
||||
{
|
||||
g_message ("Adding device '%s' (%s) using non-atomic mode setting"
|
||||
" (using atomic mode setting not allowed).",
|
||||
path, driver_name);
|
||||
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_SIMPLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ret = drmSetClientCap (fd, DRM_CLIENT_CAP_ATOMIC, 1);
|
||||
if (ret == 0)
|
||||
supports_atomic_mode_setting = TRUE;
|
||||
else
|
||||
supports_atomic_mode_setting = FALSE;
|
||||
|
||||
if (supports_atomic_mode_setting)
|
||||
{
|
||||
g_message ("Adding device '%s' (%s) using atomic mode setting.",
|
||||
path, driver_name);
|
||||
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_ATOMIC;
|
||||
}
|
||||
else
|
||||
{
|
||||
g_message ("Adding device '%s' (%s) using non-atomic mode setting.",
|
||||
path, driver_name);
|
||||
impl_device_type = META_TYPE_KMS_IMPL_DEVICE_SIMPLE;
|
||||
}
|
||||
}
|
||||
|
||||
return g_initable_new (impl_device_type, NULL, error,
|
||||
"device", device,
|
||||
"impl", impl,
|
||||
"fd", fd,
|
||||
|
Reference in New Issue
Block a user