From 51811ec7b39a164702f4ee6566c838f9cb6796b4 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Fri, 8 Mar 2024 17:48:44 +0100 Subject: [PATCH] output: Add a function to check if VRR is enabled for the output An output with enabled VRR requires that the mode is a VRR mode which also means that VRR is supported. Part-of: --- src/backends/meta-output.c | 22 +++++++++++++++ src/backends/meta-output.h | 2 ++ src/backends/native/meta-onscreen-native.c | 31 ++++------------------ 3 files changed, 29 insertions(+), 26 deletions(-) diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c index b40ce2798..b29e6c475 100644 --- a/src/backends/meta-output.c +++ b/src/backends/meta-output.c @@ -589,6 +589,28 @@ meta_output_peek_rgb_range (MetaOutput *output) return priv->rgb_range; } +gboolean +meta_output_is_vrr_enabled (MetaOutput *output) +{ + MetaOutputPrivate *priv = meta_output_get_instance_private (output); + MetaCrtc *crtc = priv->crtc; + const MetaCrtcConfig *crtc_config; + const MetaCrtcModeInfo *crtc_mode_info; + + if (!crtc) + return FALSE; + + crtc_config = meta_crtc_get_config (crtc); + g_assert (crtc_config != NULL); + g_assert (crtc_config->mode != NULL); + + crtc_mode_info = meta_crtc_mode_get_info (crtc_config->mode); + g_assert (crtc_mode_info != NULL); + + return crtc_mode_info->refresh_rate_mode == + META_CRTC_REFRESH_RATE_MODE_VARIABLE; +} + static void meta_output_init (MetaOutput *output) { diff --git a/src/backends/meta-output.h b/src/backends/meta-output.h index eba8ea570..9cfc40808 100644 --- a/src/backends/meta-output.h +++ b/src/backends/meta-output.h @@ -271,6 +271,8 @@ MetaOutputHdrMetadata * meta_output_peek_hdr_metadata (MetaOutput *output); META_EXPORT_TEST MetaOutputRGBRange meta_output_peek_rgb_range (MetaOutput *output); +gboolean meta_output_is_vrr_enabled (MetaOutput *output); + void meta_output_add_possible_clone (MetaOutput *output, MetaOutput *possible_clone); diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index bf3924842..42e811cdd 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -1740,40 +1740,19 @@ update_frame_sync_mode (MetaOnscreenNative *onscreen_native, onscreen_native->frame_sync_mode = sync_mode; } -static MetaFrameSyncMode -get_applicable_sync_mode (MetaOnscreenNative *onscreen_native) -{ - const MetaCrtcConfig *crtc_config; - const MetaCrtcModeInfo *crtc_mode_info; - - crtc_config = meta_crtc_get_config (onscreen_native->crtc); - g_assert (crtc_config != NULL); - g_assert (crtc_config->mode != NULL); - - crtc_mode_info = meta_crtc_mode_get_info (crtc_config->mode); - g_assert (crtc_mode_info != NULL); - - if (crtc_mode_info->refresh_rate_mode == - META_CRTC_REFRESH_RATE_MODE_FIXED) - return META_FRAME_SYNC_MODE_DISABLED; - - return onscreen_native->requested_frame_sync_mode; -} - static void maybe_update_frame_sync_mode (MetaOnscreenNative *onscreen_native, ClutterFrame *frame) { - MetaFrameSyncMode applicable_sync_mode; + MetaFrameSyncMode sync_mode = onscreen_native->requested_frame_sync_mode; - applicable_sync_mode = get_applicable_sync_mode (onscreen_native); + if (!meta_output_is_vrr_enabled (onscreen_native->output)) + sync_mode = META_FRAME_SYNC_MODE_DISABLED; - if (G_LIKELY (applicable_sync_mode == onscreen_native->frame_sync_mode)) + if (G_LIKELY (sync_mode == onscreen_native->frame_sync_mode)) return; - update_frame_sync_mode (onscreen_native, - frame, - applicable_sync_mode); + update_frame_sync_mode (onscreen_native, frame, sync_mode); } void