From d45104c14a2dae1990da248d94cd71ffb6ff664c Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Fri, 19 Jan 2024 19:08:19 +0100 Subject: [PATCH] backends/native: Build up connector updates in onscreen-native instead of building them in OutputKms. The KMS objects are really not the place for this. Part-of: --- src/backends/native/meta-onscreen-native.c | 82 ++++++++++++++++++++-- src/backends/native/meta-output-kms.c | 72 ------------------- src/backends/native/meta-output-kms.h | 6 -- 3 files changed, 78 insertions(+), 82 deletions(-) diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index e315a9b5f..438c01cf3 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -39,6 +39,7 @@ #include "backends/native/meta-drm-buffer-import.h" #include "backends/native/meta-drm-buffer.h" #include "backends/native/meta-frame-native.h" +#include "backends/native/meta-kms-connector.h" #include "backends/native/meta-kms-device.h" #include "backends/native/meta-kms-utils.h" #include "backends/native/meta-kms.h" @@ -474,6 +475,81 @@ meta_onscreen_native_flip_crtc (CoglOnscreen *onscreen, g_object_unref); } +static void +set_underscan (MetaOutputKms *output_kms, + MetaKmsUpdate *kms_update) +{ + MetaOutput *output = META_OUTPUT (output_kms); + const MetaOutputInfo *output_info = meta_output_get_info (output); + MetaKmsConnector *kms_connector = + meta_output_kms_get_kms_connector (output_kms); + + if (!output_info->supports_underscanning) + return; + + if (meta_output_is_underscanning (output)) + { + MetaCrtc *crtc; + const MetaCrtcConfig *crtc_config; + const MetaCrtcModeInfo *crtc_mode_info; + uint64_t hborder, vborder; + + crtc = meta_output_get_assigned_crtc (output); + crtc_config = meta_crtc_get_config (crtc); + crtc_mode_info = meta_crtc_mode_get_info (crtc_config->mode); + + hborder = MIN (128, (uint64_t) round (crtc_mode_info->width * 0.05)); + vborder = MIN (128, (uint64_t) round (crtc_mode_info->height * 0.05)); + + g_debug ("Setting underscan of connector %s to %" G_GUINT64_FORMAT " x %" G_GUINT64_FORMAT, + meta_kms_connector_get_name (kms_connector), + hborder, vborder); + + meta_kms_update_set_underscanning (kms_update, + kms_connector, + hborder, vborder); + } + else + { + g_debug ("Unsetting underscan of connector %s", + meta_kms_connector_get_name (kms_connector)); + + meta_kms_update_unset_underscanning (kms_update, + kms_connector); + } +} + +static void +set_max_bpc (MetaOutputKms *output_kms, + MetaKmsUpdate *kms_update) +{ + MetaKmsConnector *kms_connector = + meta_output_kms_get_kms_connector (output_kms); + const MetaKmsRange *range; + + range = meta_kms_connector_get_max_bpc (kms_connector); + if (range) + { + MetaOutput *output = META_OUTPUT (output_kms); + unsigned int max_bpc; + + if (!meta_output_get_max_bpc (output, &max_bpc)) + return; + + if (max_bpc >= range->min_value && max_bpc <= range->max_value) + { + meta_kms_update_set_max_bpc (kms_update, kms_connector, max_bpc); + } + else + { + g_warning ("Ignoring out of range value %u for max bpc (%u-%u)", + max_bpc, + (unsigned) range->min_value, + (unsigned) range->max_value); + } + } +} + static void meta_onscreen_native_set_crtc_mode (CoglOnscreen *onscreen, MetaKmsUpdate *kms_update, @@ -506,10 +582,8 @@ meta_onscreen_native_set_crtc_mode (CoglOnscreen *onscreen, } meta_crtc_kms_set_mode (crtc_kms, kms_update); - meta_output_kms_set_underscan (META_OUTPUT_KMS (onscreen_native->output), - kms_update); - meta_output_kms_set_max_bpc (META_OUTPUT_KMS (onscreen_native->output), - kms_update); + set_underscan (META_OUTPUT_KMS (onscreen_native->output), kms_update); + set_max_bpc (META_OUTPUT_KMS (onscreen_native->output), kms_update); } static void diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c index 7c64e4f06..c034fd2c5 100644 --- a/src/backends/native/meta-output-kms.c +++ b/src/backends/native/meta-output-kms.c @@ -53,78 +53,6 @@ meta_output_kms_get_kms_connector (MetaOutputKms *output_kms) return output_kms->kms_connector; } -void -meta_output_kms_set_underscan (MetaOutputKms *output_kms, - MetaKmsUpdate *kms_update) -{ - MetaOutput *output = META_OUTPUT (output_kms); - const MetaOutputInfo *output_info = meta_output_get_info (output); - - if (!output_info->supports_underscanning) - return; - - if (meta_output_is_underscanning (output)) - { - MetaCrtc *crtc; - const MetaCrtcConfig *crtc_config; - const MetaCrtcModeInfo *crtc_mode_info; - uint64_t hborder, vborder; - - crtc = meta_output_get_assigned_crtc (output); - crtc_config = meta_crtc_get_config (crtc); - crtc_mode_info = meta_crtc_mode_get_info (crtc_config->mode); - - hborder = MIN (128, (uint64_t) round (crtc_mode_info->width * 0.05)); - vborder = MIN (128, (uint64_t) round (crtc_mode_info->height * 0.05)); - - g_debug ("Setting underscan of connector %s to %" G_GUINT64_FORMAT " x %" G_GUINT64_FORMAT, - meta_kms_connector_get_name (output_kms->kms_connector), - hborder, vborder); - - meta_kms_update_set_underscanning (kms_update, - output_kms->kms_connector, - hborder, vborder); - } - else - { - g_debug ("Unsetting underscan of connector %s", - meta_kms_connector_get_name (output_kms->kms_connector)); - - meta_kms_update_unset_underscanning (kms_update, - output_kms->kms_connector); - } -} - -void -meta_output_kms_set_max_bpc (MetaOutputKms *output_kms, - MetaKmsUpdate *kms_update) -{ - MetaKmsConnector *kms_connector = output_kms->kms_connector; - const MetaKmsRange *range; - - range = meta_kms_connector_get_max_bpc (kms_connector); - if (range) - { - MetaOutput *output = META_OUTPUT (output_kms); - unsigned int max_bpc; - - if (!meta_output_get_max_bpc (output, &max_bpc)) - return; - - if (max_bpc >= range->min_value && max_bpc <= range->max_value) - { - meta_kms_update_set_max_bpc (kms_update, kms_connector, max_bpc); - } - else - { - g_warning ("Ignoring out of range value %u for max bpc (%u-%u)", - max_bpc, - (unsigned) range->min_value, - (unsigned) range->max_value); - } - } -} - static MetaPrivacyScreenState meta_output_kms_get_privacy_screen_state (MetaOutput *output) { diff --git a/src/backends/native/meta-output-kms.h b/src/backends/native/meta-output-kms.h index 861297701..e0eb60eb4 100644 --- a/src/backends/native/meta-output-kms.h +++ b/src/backends/native/meta-output-kms.h @@ -30,12 +30,6 @@ G_DECLARE_FINAL_TYPE (MetaOutputKms, meta_output_kms, META, OUTPUT_KMS, MetaOutputNative) -void meta_output_kms_set_underscan (MetaOutputKms *output_kms, - MetaKmsUpdate *kms_update); - -void meta_output_kms_set_max_bpc (MetaOutputKms *output_kms, - MetaKmsUpdate *kms_update); - gboolean meta_output_kms_is_privacy_screen_invalid (MetaOutputKms *output_kms); gboolean meta_output_kms_can_clone (MetaOutputKms *output_kms,