kms/impl-device: Move fd hold to update when processing

This will let us move the update ownership to the backend, allowing it
to handle it with less restrictions.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2855>
This commit is contained in:
Jonas Ådahl 2022-06-22 00:23:03 +02:00 committed by Robert Mader
parent 6d043e6a8f
commit 25172c21c9
3 changed files with 19 additions and 2 deletions

View File

@ -1018,11 +1018,11 @@ meta_kms_impl_device_process_update (MetaKmsImplDevice *impl_device,
return meta_kms_feedback_new_failed (NULL, g_steal_pointer (&error)); return meta_kms_feedback_new_failed (NULL, g_steal_pointer (&error));
} }
meta_kms_impl_device_hold_fd (impl_device); meta_kms_update_realize (update, impl_device);
feedback = klass->process_update (impl_device, update, flags); feedback = klass->process_update (impl_device, update, flags);
if (!(flags & META_KMS_UPDATE_FLAG_TEST_ONLY)) if (!(flags & META_KMS_UPDATE_FLAG_TEST_ONLY))
changes = meta_kms_impl_device_predict_states (impl_device, update); changes = meta_kms_impl_device_predict_states (impl_device, update);
meta_kms_impl_device_unhold_fd (impl_device);
meta_kms_update_free (update); meta_kms_update_free (update);

View File

@ -197,6 +197,9 @@ void meta_kms_result_listener_free (MetaKmsResultListener *listener);
void meta_kms_custom_page_flip_free (MetaKmsCustomPageFlip *custom_page_flip); void meta_kms_custom_page_flip_free (MetaKmsCustomPageFlip *custom_page_flip);
void meta_kms_update_realize (MetaKmsUpdate *update,
MetaKmsImplDevice *impl_device);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsPlaneFeedback, G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsPlaneFeedback,
meta_kms_plane_feedback_free) meta_kms_plane_feedback_free)

View File

@ -25,6 +25,7 @@
#include "backends/meta-display-config-shared.h" #include "backends/meta-display-config-shared.h"
#include "backends/native/meta-kms-connector.h" #include "backends/native/meta-kms-connector.h"
#include "backends/native/meta-kms-crtc.h" #include "backends/native/meta-kms-crtc.h"
#include "backends/native/meta-kms-impl-device.h"
#include "backends/native/meta-kms-mode-private.h" #include "backends/native/meta-kms-mode-private.h"
#include "backends/native/meta-kms-plane.h" #include "backends/native/meta-kms-plane.h"
#include "backends/native/meta-kms-private.h" #include "backends/native/meta-kms-private.h"
@ -44,6 +45,8 @@ struct _MetaKmsUpdate
GList *page_flip_listeners; GList *page_flip_listeners;
GList *result_listeners; GList *result_listeners;
MetaKmsImplDevice *impl_device;
}; };
void void
@ -902,6 +905,9 @@ meta_kms_update_new (MetaKmsDevice *device)
void void
meta_kms_update_free (MetaKmsUpdate *update) meta_kms_update_free (MetaKmsUpdate *update)
{ {
if (update->impl_device)
meta_kms_impl_device_unhold_fd (update->impl_device);
g_list_free_full (update->result_listeners, g_list_free_full (update->result_listeners,
(GDestroyNotify) meta_kms_result_listener_free); (GDestroyNotify) meta_kms_result_listener_free);
g_list_free_full (update->plane_assignments, g_list_free_full (update->plane_assignments,
@ -917,3 +923,11 @@ meta_kms_update_free (MetaKmsUpdate *update)
g_free (update); g_free (update);
} }
void
meta_kms_update_realize (MetaKmsUpdate *update,
MetaKmsImplDevice *impl_device)
{
update->impl_device = impl_device;
meta_kms_impl_device_hold_fd (impl_device);
}