diff --git a/src/backends/native/meta-kms-connector.c b/src/backends/native/meta-kms-connector.c index 1ff274f1e..6948ea686 100644 --- a/src/backends/native/meta-kms-connector.c +++ b/src/backends/native/meta-kms-connector.c @@ -261,6 +261,14 @@ meta_kms_connector_is_broadcast_rgb_supported (MetaKmsConnector *connector, 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) diff --git a/src/backends/native/meta-kms-connector.h b/src/backends/native/meta-kms-connector.h index 30919d032..e4a481632 100644 --- a/src/backends/native/meta-kms-connector.h +++ b/src/backends/native/meta-kms-connector.h @@ -107,3 +107,6 @@ gboolean meta_kms_connector_is_broadcast_rgb_supported (MetaKmsConnector *conn 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 3eab71b3c..e4680bb07 100644 --- a/src/backends/native/meta-kms-update.c +++ b/src/backends/native/meta-kms-update.c @@ -430,6 +430,8 @@ 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; diff --git a/src/backends/native/meta-onscreen-native.c b/src/backends/native/meta-onscreen-native.c index 6db9abd5c..a1cfce075 100644 --- a/src/backends/native/meta-onscreen-native.c +++ b/src/backends/native/meta-onscreen-native.c @@ -624,31 +624,28 @@ static void set_max_bpc (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); - const MetaKmsRange *range; + unsigned int max_bpc; - range = meta_kms_connector_get_max_bpc (kms_connector); - if (range) + if (!meta_output_get_max_bpc (output, &max_bpc)) + return; + + if (output_info->max_bpc_min == 0 && output_info->max_bpc_max == 0) + return; + + if (max_bpc < output_info->max_bpc_min || max_bpc > output_info->max_bpc_max) { - 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); - } + g_warning ("Ignoring out of range value %u for max bpc (%u-%u)", + max_bpc, + (unsigned) output_info->max_bpc_min, + (unsigned) output_info->max_bpc_max); + return; } + + meta_kms_update_set_max_bpc (kms_update, kms_connector, max_bpc); } static void