From e3b659cfe8139f0da00028e5cd405feb60e4478d Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 6 Sep 2023 17:30:00 +0200 Subject: [PATCH] monitor-manager: Add logging to enabling and disabling HDR mode It's hard to tell why turning on HDR mode failed without these log messages. It could be missing support in the sink (EDID/DisplayID) or missing support in the driver/display hardware (connector properties) or just a failure turning it on. Part-of: --- src/backends/meta-monitor-manager.c | 72 +++++++++++++++++++-------- src/backends/meta-output.c | 15 ++++++ src/backends/meta-output.h | 2 + src/backends/native/meta-output-kms.c | 18 ++++++- 4 files changed, 84 insertions(+), 23 deletions(-) diff --git a/src/backends/meta-monitor-manager.c b/src/backends/meta-monitor-manager.c index 15c219a54..3b836f327 100644 --- a/src/backends/meta-monitor-manager.c +++ b/src/backends/meta-monitor-manager.c @@ -501,6 +501,10 @@ ensure_hdr_settings (MetaMonitorManager *manager) .active = TRUE, .eotf = META_OUTPUT_HDR_METADATA_EOTF_PQ, }; + + meta_topic (META_DEBUG_COLOR, + "MonitorManager: Trying to enabling HDR mode " + "(Colorimetry: bt.2020, TF: PQ, HDR Metadata: Minimal):"); } else { @@ -508,6 +512,10 @@ ensure_hdr_settings (MetaMonitorManager *manager) hdr_metadata = (MetaOutputHdrMetadata) { .active = FALSE, }; + + meta_topic (META_DEBUG_COLOR, + "MonitorManager: Trying to enable default mode " + "(Colorimetry: default, TF: default, HDR Metadata: None):"); } for (l = manager->monitors; l; l = l->next) @@ -517,27 +525,6 @@ ensure_hdr_settings (MetaMonitorManager *manager) if (!meta_monitor_set_color_space (monitor, color_space, &error)) { - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) - continue; - - g_warning ("Failed to set color space on monitor %s: %s", - meta_monitor_get_display_name (monitor), error->message); - - meta_monitor_set_color_space (monitor, - META_OUTPUT_COLORSPACE_DEFAULT, - NULL); - - continue; - } - - if (!meta_monitor_set_hdr_metadata (monitor, &hdr_metadata, &error)) - { - if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) - continue; - - g_warning ("Failed to set HDR metadata on monitor %s: %s", - meta_monitor_get_display_name (monitor), error->message); - meta_monitor_set_color_space (monitor, META_OUTPUT_COLORSPACE_DEFAULT, NULL); @@ -545,8 +532,51 @@ ensure_hdr_settings (MetaMonitorManager *manager) .active = FALSE, }, NULL); + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) + { + meta_topic (META_DEBUG_COLOR, + "MonitorManager: Colorimetry not supported " + "on monitor %s", + meta_monitor_get_display_name (monitor)); + } + else + { + g_warning ("Failed to set color space on monitor %s: %s", + meta_monitor_get_display_name (monitor), error->message); + } + continue; } + + if (!meta_monitor_set_hdr_metadata (monitor, &hdr_metadata, &error)) + { + meta_monitor_set_color_space (monitor, + META_OUTPUT_COLORSPACE_DEFAULT, + NULL); + meta_monitor_set_hdr_metadata (monitor, &(MetaOutputHdrMetadata) { + .active = FALSE, + }, NULL); + + if (g_error_matches (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED)) + { + meta_topic (META_DEBUG_COLOR, + "MonitorManager: HDR Metadata not supported " + "on monitor %s", + meta_monitor_get_display_name (monitor)); + } + else + { + g_warning ("Failed to set HDR metadata on monitor %s: %s", + meta_monitor_get_display_name (monitor), + error->message); + } + + continue; + } + + meta_topic (META_DEBUG_COLOR, + "MonitorManager: successfully set on monitor %s", + meta_monitor_get_display_name (monitor)); } } diff --git a/src/backends/meta-output.c b/src/backends/meta-output.c index 9f7bd32a6..f40fc6ec1 100644 --- a/src/backends/meta-output.c +++ b/src/backends/meta-output.c @@ -565,6 +565,21 @@ meta_output_peek_color_space (MetaOutput *output) return priv->color_space; } +const char * +meta_output_colorspace_get_name (MetaOutputColorspace color_space) +{ + switch (color_space) + { + case META_OUTPUT_COLORSPACE_UNKNOWN: + return "Unknown"; + case META_OUTPUT_COLORSPACE_DEFAULT: + return "Default"; + case META_OUTPUT_COLORSPACE_BT2020: + return "bt.2020"; + } + g_assert_not_reached (); +} + gboolean meta_output_is_hdr_metadata_supported (MetaOutput *output, MetaOutputHdrMetadataEOTF eotf) diff --git a/src/backends/meta-output.h b/src/backends/meta-output.h index b1f5acc13..03a4cc385 100644 --- a/src/backends/meta-output.h +++ b/src/backends/meta-output.h @@ -162,6 +162,8 @@ gboolean meta_tile_info_equal (MetaTileInfo *a, MetaTileInfo *b); +const char * meta_output_colorspace_get_name (MetaOutputColorspace color_space); + #define META_TYPE_OUTPUT_INFO (meta_output_info_get_type ()) META_EXPORT_TEST GType meta_output_info_get_type (void); diff --git a/src/backends/native/meta-output-kms.c b/src/backends/native/meta-output-kms.c index 0e7d0a9eb..7c64e4f06 100644 --- a/src/backends/native/meta-output-kms.c +++ b/src/backends/native/meta-output-kms.c @@ -148,13 +148,27 @@ meta_output_kms_is_color_space_supported (MetaOutput *output, output_info = meta_output_get_info (output); if (!meta_output_info_is_color_space_supported (output_info, color_space)) - return FALSE; + { + meta_topic (META_DEBUG_COLOR, + "MetaOutput: Output %s signals that it doesn't support " + "Colorspace %s", + meta_output_get_name (output), + meta_output_colorspace_get_name (color_space)); + return FALSE; + } connector_state = meta_kms_connector_get_current_state (output_kms->kms_connector); if (!(connector_state->colorspace.supported & (1 << color_space))) - return FALSE; + { + meta_topic (META_DEBUG_COLOR, + "MetaOutput: KMS Connector for output %s doesn't support " + "Colorspace %s", + meta_output_get_name (output), + meta_output_colorspace_get_name (color_space)); + return FALSE; + } return TRUE; }