From a8d724d0585248c02dc9f69d0e911fd6c128e2f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 16 Jul 2020 23:29:31 +0200 Subject: [PATCH] kms/impl: Manage a list of impl devices Accessing the device list directly from MetaKms might not be safe if we introduce threads, so keep a list completely within the impl context. Part-of: --- src/backends/native/meta-kms-device.c | 2 ++ src/backends/native/meta-kms-impl-device.c | 2 ++ src/backends/native/meta-kms-impl.c | 26 ++++++++++++++++++++++ src/backends/native/meta-kms-impl.h | 6 +++++ 4 files changed, 36 insertions(+) diff --git a/src/backends/native/meta-kms-device.c b/src/backends/native/meta-kms-device.c index dc0dfa0fe..a8abd8842 100644 --- a/src/backends/native/meta-kms-device.c +++ b/src/backends/native/meta-kms-device.c @@ -270,6 +270,8 @@ create_impl_device_in_impl (MetaKmsImpl *impl, if (!impl_device) return FALSE; + meta_kms_impl_add_impl_device (impl, impl_device); + data->out_impl_device = impl_device; data->out_crtcs = meta_kms_impl_device_copy_crtcs (impl_device); data->out_connectors = meta_kms_impl_device_copy_connectors (impl_device); diff --git a/src/backends/native/meta-kms-impl-device.c b/src/backends/native/meta-kms-impl-device.c index 1f2cfb3ed..3581f2aae 100644 --- a/src/backends/native/meta-kms-impl-device.c +++ b/src/backends/native/meta-kms-impl-device.c @@ -703,6 +703,8 @@ meta_kms_impl_device_finalize (GObject *object) MetaKmsImplDevicePrivate *priv = meta_kms_impl_device_get_instance_private (impl_device); + meta_kms_impl_remove_impl_device (priv->impl, impl_device); + g_list_free_full (priv->planes, g_object_unref); g_list_free_full (priv->crtcs, g_object_unref); g_list_free_full (priv->connectors, g_object_unref); diff --git a/src/backends/native/meta-kms-impl.c b/src/backends/native/meta-kms-impl.c index ee9625ec8..29faf932b 100644 --- a/src/backends/native/meta-kms-impl.c +++ b/src/backends/native/meta-kms-impl.c @@ -22,6 +22,8 @@ #include "backends/native/meta-kms-impl.h" +#include "backends/native/meta-kms-private.h" + enum { PROP_0, @@ -32,6 +34,8 @@ enum typedef struct _MetaKmsImplPrivate { MetaKms *kms; + + GList *impl_devices; } MetaKmsImplPrivate; G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (MetaKmsImpl, meta_kms_impl, G_TYPE_OBJECT) @@ -44,6 +48,28 @@ meta_kms_impl_get_kms (MetaKmsImpl *impl) return priv->kms; } +void +meta_kms_impl_add_impl_device (MetaKmsImpl *impl, + MetaKmsImplDevice *impl_device) +{ + MetaKmsImplPrivate *priv = meta_kms_impl_get_instance_private (impl); + + meta_assert_in_kms_impl (priv->kms); + + priv->impl_devices = g_list_append (priv->impl_devices, impl_device); +} + +void +meta_kms_impl_remove_impl_device (MetaKmsImpl *impl, + MetaKmsImplDevice *impl_device) +{ + MetaKmsImplPrivate *priv = meta_kms_impl_get_instance_private (impl); + + meta_assert_in_kms_impl (priv->kms); + + priv->impl_devices = g_list_remove (priv->impl_devices, impl_device); +} + MetaKmsFeedback * meta_kms_impl_process_update (MetaKmsImpl *impl, MetaKmsUpdate *update) diff --git a/src/backends/native/meta-kms-impl.h b/src/backends/native/meta-kms-impl.h index c22f78219..11498a795 100644 --- a/src/backends/native/meta-kms-impl.h +++ b/src/backends/native/meta-kms-impl.h @@ -47,6 +47,12 @@ MetaKms * meta_kms_impl_get_kms (MetaKmsImpl *impl); MetaKmsFeedback * meta_kms_impl_process_update (MetaKmsImpl *impl, MetaKmsUpdate *update); +void meta_kms_impl_add_impl_device (MetaKmsImpl *impl, + MetaKmsImplDevice *impl_device); + +void meta_kms_impl_remove_impl_device (MetaKmsImpl *impl, + MetaKmsImplDevice *impl_device); + void meta_kms_impl_handle_page_flip_callback (MetaKmsImpl *impl, MetaKmsPageFlipData *page_flip_data);