From 5ba2d79076df5380dff2c069ae276270cb7b1a14 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20=C3=85dahl?= Date: Thu, 1 Oct 2020 18:28:13 +0200 Subject: [PATCH] kms/update: Make custom page flip be per update Custom page flips are meant to allow using e.g. EGLStream API to indirectly trigger page flip queueing, when the KMS API cannot be used directly. This is really something that is specific to a device, so instead of making part of the page flip API, make it a configuration of the update itself. Part-of: --- .../native/meta-kms-impl-device-simple.c | 9 +++-- src/backends/native/meta-kms-update-private.h | 6 ++-- src/backends/native/meta-kms-update.c | 36 +++++++++---------- src/backends/native/meta-kms-update.h | 9 ++--- src/backends/native/meta-renderer-native.c | 20 +++++------ 5 files changed, 39 insertions(+), 41 deletions(-) diff --git a/src/backends/native/meta-kms-impl-device-simple.c b/src/backends/native/meta-kms-impl-device-simple.c index 12d2af3e3..49bd89073 100644 --- a/src/backends/native/meta-kms-impl-device-simple.c +++ b/src/backends/native/meta-kms-impl-device-simple.c @@ -716,6 +716,7 @@ process_page_flip (MetaKmsImplDevice *impl_device, MetaKmsPlaneAssignment *plane_assignment; MetaKmsPageFlipData *page_flip_data; MetaKmsCustomPageFlipFunc custom_page_flip_func; + gpointer custom_page_flip_user_data; int fd; int ret; @@ -729,10 +730,12 @@ process_page_flip (MetaKmsImplDevice *impl_device, page_flip->user_data); fd = meta_kms_impl_device_get_fd (impl_device); - custom_page_flip_func = page_flip->custom_page_flip_func; + meta_kms_update_get_custom_page_flip_func (update, + &custom_page_flip_func, + &custom_page_flip_user_data); if (custom_page_flip_func) { - ret = custom_page_flip_func (page_flip->custom_page_flip_user_data, + ret = custom_page_flip_func (custom_page_flip_user_data, meta_kms_page_flip_data_ref (page_flip_data)); } else @@ -773,7 +776,7 @@ process_page_flip (MetaKmsImplDevice *impl_device, refresh_rate, page_flip_data, custom_page_flip_func, - page_flip->custom_page_flip_user_data); + custom_page_flip_user_data); } else { diff --git a/src/backends/native/meta-kms-update-private.h b/src/backends/native/meta-kms-update-private.h index 8863cd93c..90fb475fe 100644 --- a/src/backends/native/meta-kms-update-private.h +++ b/src/backends/native/meta-kms-update-private.h @@ -92,8 +92,6 @@ typedef struct _MetaKmsPageFlip const MetaKmsPageFlipFeedback *feedback; MetaKmsPageFlipFlag flags; gpointer user_data; - MetaKmsCustomPageFlipFunc custom_page_flip_func; - gpointer custom_page_flip_user_data; } MetaKmsPageFlip; void meta_kms_plane_feedback_free (MetaKmsPlaneFeedback *plane_feedback); @@ -129,6 +127,10 @@ GList * meta_kms_update_get_connector_updates (MetaKmsUpdate *update); GList * meta_kms_update_get_crtc_gammas (MetaKmsUpdate *update); +void meta_kms_update_get_custom_page_flip_func (MetaKmsUpdate *update, + MetaKmsCustomPageFlipFunc *custom_page_flip_func, + gpointer *custom_page_flip_user_data); + G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaKmsPlaneFeedback, meta_kms_plane_feedback_free) diff --git a/src/backends/native/meta-kms-update.c b/src/backends/native/meta-kms-update.c index f52129e00..0436a1d3d 100644 --- a/src/backends/native/meta-kms-update.c +++ b/src/backends/native/meta-kms-update.c @@ -40,6 +40,9 @@ struct _MetaKmsUpdate GList *page_flips; GList *connector_updates; GList *crtc_gammas; + + MetaKmsCustomPageFlipFunc custom_page_flip_func; + gpointer custom_page_flip_user_data; }; void @@ -342,28 +345,14 @@ meta_kms_update_page_flip (MetaKmsUpdate *update, } void -meta_kms_update_custom_page_flip (MetaKmsUpdate *update, - MetaKmsCrtc *crtc, - const MetaKmsPageFlipFeedback *feedback, - gpointer user_data, - MetaKmsCustomPageFlipFunc custom_page_flip_func, - gpointer custom_page_flip_user_data) +meta_kms_update_set_custom_page_flip (MetaKmsUpdate *update, + MetaKmsCustomPageFlipFunc func, + gpointer user_data) { - MetaKmsPageFlip *page_flip; - g_assert (!meta_kms_update_is_sealed (update)); - g_assert (meta_kms_crtc_get_device (crtc) == update->device); - page_flip = g_new0 (MetaKmsPageFlip, 1); - *page_flip = (MetaKmsPageFlip) { - .crtc = crtc, - .feedback = feedback, - .user_data = user_data, - .custom_page_flip_func = custom_page_flip_func, - .custom_page_flip_user_data = custom_page_flip_user_data, - }; - - update->page_flips = g_list_prepend (update->page_flips, page_flip); + update->custom_page_flip_func = func; + update->custom_page_flip_user_data = user_data; } void @@ -451,6 +440,15 @@ meta_kms_update_get_device (MetaKmsUpdate *update) return update->device; } +void +meta_kms_update_get_custom_page_flip_func (MetaKmsUpdate *update, + MetaKmsCustomPageFlipFunc *custom_page_flip_func, + gpointer *custom_page_flip_user_data) +{ + *custom_page_flip_func = update->custom_page_flip_func; + *custom_page_flip_user_data = update->custom_page_flip_user_data; +} + MetaKmsUpdate * meta_kms_update_new (MetaKmsDevice *device) { diff --git a/src/backends/native/meta-kms-update.h b/src/backends/native/meta-kms-update.h index f35882b47..cb5c5b08b 100644 --- a/src/backends/native/meta-kms-update.h +++ b/src/backends/native/meta-kms-update.h @@ -128,12 +128,9 @@ void meta_kms_update_page_flip (MetaKmsUpdate *update, MetaKmsPageFlipFlag flags, gpointer user_data); -void meta_kms_update_custom_page_flip (MetaKmsUpdate *update, - MetaKmsCrtc *crtc, - const MetaKmsPageFlipFeedback *feedback, - gpointer user_data, - MetaKmsCustomPageFlipFunc custom_page_flip_func, - gpointer custom_page_flip_user_data); +void meta_kms_update_set_custom_page_flip (MetaKmsUpdate *update, + MetaKmsCustomPageFlipFunc func, + gpointer user_data); void meta_kms_plane_assignment_set_cursor_hotspot (MetaKmsPlaneAssignment *plane_assignment, int x, diff --git a/src/backends/native/meta-renderer-native.c b/src/backends/native/meta-renderer-native.c index 5cb884cb8..c32cea3d3 100644 --- a/src/backends/native/meta-renderer-native.c +++ b/src/backends/native/meta-renderer-native.c @@ -1291,24 +1291,22 @@ meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen, } meta_crtc_kms_assign_primary_plane (crtc_kms, buffer, kms_update); - meta_kms_update_page_flip (kms_update, - meta_crtc_kms_get_kms_crtc (crtc_kms), - &page_flip_feedback, - flags, - g_object_ref (view)); break; #ifdef HAVE_EGL_DEVICE case META_RENDERER_NATIVE_MODE_EGL_DEVICE: - meta_kms_update_custom_page_flip (kms_update, - meta_crtc_kms_get_kms_crtc (crtc_kms), - &page_flip_feedback, - g_object_ref (view), - custom_egl_stream_page_flip, - onscreen_native); + meta_kms_update_set_custom_page_flip (kms_update, + custom_egl_stream_page_flip, + onscreen_native); break; #endif } + + meta_kms_update_page_flip (kms_update, + meta_crtc_kms_get_kms_crtc (crtc_kms), + &page_flip_feedback, + flags, + g_object_ref (view)); } static void