From cca07612b8590d08caedf382e5ec22cff0f09eac Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Fri, 17 Mar 2023 01:17:45 +0100 Subject: [PATCH] output: Check the EDID for the supported sink Colorimetry Just like the HDR Metadata property the Colorspace property values only indicate that the display driver supports signaling certain colorimetry. It does not indidcate that the sink actually supports processing the colorimetry. For this we have to look up the colorimetry support in the EDID. The default colorimetry is always supported. If we want bt.2020 we might get either the RGB or YCC variant even if we ask for the RGB variant but there is nothing we can do about it so let's just pretend it's a driver issue. Part-of: --- src/backends/meta-output.c | 29 +++++++++++++++++++++++---- src/backends/meta-output.h | 6 +++++- src/backends/native/meta-output-kms.c | 20 +++++++++++++----- 3 files changed, 45 insertions(+), 10 deletions(-) diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c index efa279aa3..2610b3509 100644 --- a/src/backends/meta-output.c +++ b/src/backends/meta-output.c @@ -528,17 +528,38 @@ meta_output_set_privacy_screen_enabled (MetaOutput *output, return TRUE; } +gboolean +meta_output_info_is_color_space_supported (const MetaOutputInfo *output_info, + MetaOutputColorspace color_space) +{ + MetaEdidColorimetry colorimetry; + + if (!output_info->edid_info) + return FALSE; + + colorimetry = output_info->edid_info->colorimetry; + + switch (color_space) + { + case META_OUTPUT_COLORSPACE_DEFAULT: + return TRUE; + case META_OUTPUT_COLORSPACE_BT2020: + return !!(colorimetry & META_EDID_COLORIMETRY_BT2020RGB); + default: + return FALSE; + } +} + gboolean meta_output_is_color_space_supported (MetaOutput *output, MetaOutputColorspace color_space) { MetaOutputClass *output_class = META_OUTPUT_GET_CLASS (output); - uint64_t supported = 0; - if (output_class->get_supported_color_spaces) - supported = output_class->get_supported_color_spaces (output); + if (!output_class->is_color_space_supported) + return FALSE; - return supported & (1 << color_space); + return output_class->is_color_space_supported (output, color_space); } void diff --git a/src/backends/meta-output.h b/src/backends/meta-output.h index ba86e2c27..08e59ddd1 100644 --- a/src/backends/meta-output.h +++ b/src/backends/meta-output.h @@ -182,6 +182,9 @@ META_EXPORT_TEST void meta_output_info_parse_edid (MetaOutputInfo *output_info, GBytes *edid); +gboolean meta_output_info_is_color_space_supported (const MetaOutputInfo *output_info, + MetaOutputColorspace color_space); + gboolean meta_output_is_laptop (MetaOutput *output); G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaOutputInfo, meta_output_info_unref) @@ -198,7 +201,8 @@ struct _MetaOutputClass gboolean (* set_privacy_screen_enabled) (MetaOutput *output, gboolean enabled, GError **error); - uint64_t (* get_supported_color_spaces) (MetaOutput *output); + gboolean (* is_color_space_supported) (MetaOutput *output, + MetaOutputColorspace color_space); gboolean (* is_hdr_metadata_supported) (MetaOutput *output); }; diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c index 5107dd069..f071e4d11 100644 --- a/src/backends/native/meta-output-kms.c +++ b/src/backends/native/meta-output-kms.c @@ -139,16 +139,26 @@ meta_output_kms_get_privacy_screen_state (MetaOutput *output) return connector_state->privacy_screen_state; } -static uint64_t -meta_output_kms_get_supported_color_spaces (MetaOutput *output) +static gboolean +meta_output_kms_is_color_space_supported (MetaOutput *output, + MetaOutputColorspace color_space) { MetaOutputKms *output_kms = META_OUTPUT_KMS (output); const MetaKmsConnectorState *connector_state; + const MetaOutputInfo *output_info; + + output_info = meta_output_get_info (output); + + if (!meta_output_info_is_color_space_supported (output_info, color_space)) + return FALSE; connector_state = meta_kms_connector_get_current_state (output_kms->kms_connector); - return connector_state->colorspace.supported; + if (!(connector_state->colorspace.supported & (1 << color_space))) + return FALSE; + + return TRUE; } static gboolean @@ -535,8 +545,8 @@ meta_output_kms_class_init (MetaOutputKmsClass *klass) output_class->get_privacy_screen_state = meta_output_kms_get_privacy_screen_state; - output_class->get_supported_color_spaces = - meta_output_kms_get_supported_color_spaces; + output_class->is_color_space_supported = + meta_output_kms_is_color_space_supported; output_class->is_hdr_metadata_supported = meta_output_kms_is_hdr_metadata_supported;