From b102b6eca718692fde220cf054f363591c6e850f Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Mon, 29 Jan 2024 17:02:17 +0100 Subject: [PATCH] kms/connector: Remove getters for state tracked by KmsConnectorState This also removes some g_return_if_fail's because the test suite expects to be able to create arbitrary KmsUpdates even if they don't make sense for the real state. We just get lucky that the test suite isn't constructing updates with color space and hdr changes, yet. Part-of: --- src/backends/native/meta-kms-connector.c | 58 ++---------------------- src/backends/native/meta-kms-connector.h | 14 ------ src/backends/native/meta-kms-update.c | 5 -- src/backends/native/meta-output-kms.c | 15 +++++- 4 files changed, 18 insertions(+), 74 deletions(-) diff --git a/src/backends/native/meta-kms-connector.c b/src/backends/native/meta-kms-connector.c index 93720cba4..93cbe7003 100644 --- a/src/backends/native/meta-kms-connector.c +++ b/src/backends/native/meta-kms-connector.c @@ -138,23 +138,6 @@ meta_kms_connector_get_name (MetaKmsConnector *connector) return connector->name; } -gboolean -meta_kms_connector_can_clone (MetaKmsConnector *connector, - MetaKmsConnector *other_connector) -{ - MetaKmsConnectorState *state = connector->current_state; - MetaKmsConnectorState *other_state = other_connector->current_state; - - if (state->common_possible_clones == 0 || - other_state->common_possible_clones == 0) - return FALSE; - - if (state->encoder_device_idxs != other_state->encoder_device_idxs) - return FALSE; - - return TRUE; -} - MetaKmsMode * meta_kms_connector_get_preferred_mode (MetaKmsConnector *connector) { @@ -209,34 +192,6 @@ sync_fd_held (MetaKmsConnector *connector, connector->fd_held = should_hold_fd; } -gboolean -meta_kms_connector_is_color_space_supported (MetaKmsConnector *connector, - MetaOutputColorspace color_space) -{ - return !!(connector->current_state->colorspace.supported & (1 << color_space)); -} - -gboolean -meta_kms_connector_is_hdr_metadata_supported (MetaKmsConnector *connector) -{ - return connector->current_state->hdr.supported; -} - -gboolean -meta_kms_connector_is_broadcast_rgb_supported (MetaKmsConnector *connector, - MetaOutputRGBRange broadcast_rgb) -{ - return !!(connector->current_state->broadcast_rgb.supported & (1 << broadcast_rgb)); -} - -gboolean -meta_kms_connector_is_max_bpc_supported (MetaKmsConnector *connector, - int max_bpc) -{ - return max_bpc >= connector->current_state->max_bpc.min_value && - max_bpc <= connector->current_state->max_bpc.max_value; -} - static void set_panel_orientation (MetaKmsConnectorState *state, MetaKmsProp *panel_orientation) @@ -1251,24 +1206,21 @@ meta_kms_connector_predict_state_in_impl (MetaKmsConnector *connector, if (connector_update->colorspace.has_update) { - g_warn_if_fail (meta_kms_connector_is_color_space_supported ( - connector, - connector_update->colorspace.value)); + g_warn_if_fail (current_state->colorspace.supported & + (1 << connector_update->colorspace.value)); current_state->colorspace.value = connector_update->colorspace.value; } if (connector_update->hdr.has_update) { - g_warn_if_fail (meta_kms_connector_is_hdr_metadata_supported ( - connector)); + g_warn_if_fail (current_state->hdr.supported); current_state->hdr.value = connector_update->hdr.value; } if (connector_update->broadcast_rgb.has_update) { - g_warn_if_fail (meta_kms_connector_is_broadcast_rgb_supported ( - connector, - connector_update->broadcast_rgb.value)); + g_warn_if_fail (current_state->broadcast_rgb.supported & + (1 << connector_update->broadcast_rgb.value)); current_state->broadcast_rgb.value = connector_update->broadcast_rgb.value; } } diff --git a/src/backends/native/meta-kms-connector.h b/src/backends/native/meta-kms-connector.h index 50e8c962f..031e2166e 100644 --- a/src/backends/native/meta-kms-connector.h +++ b/src/backends/native/meta-kms-connector.h @@ -94,22 +94,8 @@ uint32_t meta_kms_connector_get_id (MetaKmsConnector *connector); const char * meta_kms_connector_get_name (MetaKmsConnector *connector); -gboolean meta_kms_connector_can_clone (MetaKmsConnector *connector, - MetaKmsConnector *other_connector); - META_EXPORT_TEST MetaKmsMode * meta_kms_connector_get_preferred_mode (MetaKmsConnector *connector); META_EXPORT_TEST const MetaKmsConnectorState * meta_kms_connector_get_current_state (MetaKmsConnector *connector); - -gboolean meta_kms_connector_is_color_space_supported (MetaKmsConnector *connector, - MetaOutputColorspace color_space); - -gboolean meta_kms_connector_is_broadcast_rgb_supported (MetaKmsConnector *connector, - MetaOutputRGBRange broadcast_rgb); - -gboolean meta_kms_connector_is_hdr_metadata_supported (MetaKmsConnector *connector); - -gboolean meta_kms_connector_is_max_bpc_supported (MetaKmsConnector *connector, - int max_bpc); diff --git a/src/backends/native/meta-kms-update.c b/src/backends/native/meta-kms-update.c index e4680bb07..8e23527ed 100644 --- a/src/backends/native/meta-kms-update.c +++ b/src/backends/native/meta-kms-update.c @@ -430,8 +430,6 @@ meta_kms_update_set_max_bpc (MetaKmsUpdate *update, MetaKmsConnectorUpdate *connector_update; g_assert (meta_kms_connector_get_device (connector) == update->device); - g_return_if_fail (meta_kms_connector_is_max_bpc_supported (connector, - max_bpc)); connector_update = ensure_connector_update (update, connector); connector_update->max_bpc.value = max_bpc; @@ -460,7 +458,6 @@ meta_kms_update_set_hdr_metadata (MetaKmsUpdate *update, MetaKmsConnectorUpdate *connector_update; g_assert (meta_kms_connector_get_device (connector) == update->device); - g_return_if_fail (meta_kms_connector_is_hdr_metadata_supported (connector)); connector_update = ensure_connector_update (update, connector); connector_update->hdr.has_update = TRUE; @@ -478,8 +475,6 @@ meta_kms_update_set_broadcast_rgb (MetaKmsUpdate *update, MetaKmsConnectorUpdate *connector_update; g_assert (meta_kms_connector_get_device (connector) == update->device); - g_return_if_fail (meta_kms_connector_is_broadcast_rgb_supported (connector, - rgb_range)); connector_update = ensure_connector_update (update, connector); connector_update->broadcast_rgb.has_update = TRUE; diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c index 109d34cf2..a25fdaf81 100644 --- a/src/backends/native/meta-output-kms.c +++ b/src/backends/native/meta-output-kms.c @@ -75,8 +75,19 @@ gboolean meta_output_kms_can_clone (MetaOutputKms *output_kms, MetaOutputKms *other_output_kms) { - return meta_kms_connector_can_clone (output_kms->kms_connector, - other_output_kms->kms_connector); + const MetaKmsConnectorState *state = + meta_kms_connector_get_current_state (output_kms->kms_connector); + const MetaKmsConnectorState *other_state = + meta_kms_connector_get_current_state (other_output_kms->kms_connector); + + if (state->common_possible_clones == 0 || + other_state->common_possible_clones == 0) + return FALSE; + + if (state->encoder_device_idxs != other_state->encoder_device_idxs) + return FALSE; + + return TRUE; } static GBytes *