From 1c25b75571ac51109b9c9203e3df92f598995777 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Mon, 1 Jul 2019 10:49:03 +0200 Subject: [PATCH] kms-impl-device: Fail if we can't enable universal planes We currently don't handle the lack of DRM_CLIENT_CAP_UNIVERSAL_PLANES KMS capability. Fail constructing a device that can't handle this up front, so later made assumptions, such as presence of a primary plane, are actually valid. If we want to support lack of said capability, the required planes need to be emulated by a dummy MetaKmsPlane object. https://gitlab.gnome.org/GNOME/mutter/merge_requests/665 --- src/backends/native/meta-kms-device.c | 4 +++- src/backends/native/meta-kms-impl-device.c | 19 ++++++++++++++----- src/backends/native/meta-kms-impl-device.h | 7 ++++--- 3 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/backends/native/meta-kms-device.c b/src/backends/native/meta-kms-device.c index 3a626c58c..27dc65e6b 100644 --- a/src/backends/native/meta-kms-device.c +++ b/src/backends/native/meta-kms-device.c @@ -156,7 +156,9 @@ create_impl_device_in_impl (MetaKmsImpl *impl, CreateImplDeviceData *data = user_data; MetaKmsImplDevice *impl_device; - impl_device = meta_kms_impl_device_new (data->device, impl, data->fd); + impl_device = meta_kms_impl_device_new (data->device, impl, data->fd, error); + if (!impl_device) + return FALSE; data->out_impl_device = impl_device; data->out_crtcs = meta_kms_impl_device_copy_crtcs (impl_device); diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index 5f7a43daf..eb5e350ed 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -307,23 +307,32 @@ meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device) } MetaKmsImplDevice * -meta_kms_impl_device_new (MetaKmsDevice *device, - MetaKmsImpl *impl, - int fd) +meta_kms_impl_device_new (MetaKmsDevice *device, + MetaKmsImpl *impl, + int fd, + GError **error) { MetaKms *kms = meta_kms_impl_get_kms (impl); MetaKmsImplDevice *impl_device; + int ret; drmModeRes *drm_resources; meta_assert_in_kms_impl (kms); + ret = drmSetClientCap (fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); + if (ret != 0) + { + g_set_error (error, G_IO_ERROR, g_io_error_from_errno (-ret), + "Failed to activate universal planes: %s", + g_strerror (-ret)); + return NULL; + } + impl_device = g_object_new (META_TYPE_KMS_IMPL_DEVICE, NULL); impl_device->device = device; impl_device->impl = impl; impl_device->fd = fd; - drmSetClientCap (fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); - drm_resources = drmModeGetResources (fd); init_crtcs (impl_device, drm_resources); diff --git a/src/backends/native/meta-kms-impl-device.h b/src/backends/native/meta-kms-impl-device.h index 6c4b4e540..5390ef575 100644 --- a/src/backends/native/meta-kms-impl-device.h +++ b/src/backends/native/meta-kms-impl-device.h @@ -57,8 +57,9 @@ void meta_kms_impl_device_update_states (MetaKmsImplDevice *impl_device); int meta_kms_impl_device_close (MetaKmsImplDevice *impl_device); -MetaKmsImplDevice * meta_kms_impl_device_new (MetaKmsDevice *device, - MetaKmsImpl *kms_impl, - int fd); +MetaKmsImplDevice * meta_kms_impl_device_new (MetaKmsDevice *device, + MetaKmsImpl *kms_impl, + int fd, + GError **error); #endif /* META_KMS_IMPL_DEVICE_H */