kms/device: Add SUPPORTS_COLOR_MODES flag and use it to guard HDR/color

Technically the impl device simple now also supports HDR, but there are
too many things that can go wrong, such as the colorspace prop getting
set, but not the HDR transfer function. For now, we will say that the
simple device impl does not have usable HDR support.

This gets picked up by the MetaOutputKms and propagtes the state to
everywhere.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4357>
This commit is contained in:
Sebastian Wick 2025-03-25 11:40:50 +01:00 committed by Bruce Leidl
parent 9288845959
commit 8b20a75df9
6 changed files with 16 additions and 4 deletions

View File

@ -785,6 +785,9 @@ meta_kms_device_new (MetaKms *kms,
if (device->caps.addfb2_modifiers)
device->flags |= META_KMS_DEVICE_FLAG_HAS_ADDFB2;
if (device->caps.supports_color_modes)
device->flags |= META_KMS_DEVICE_FLAG_SUPPORTS_COLOR_MODES;
return device;
}

View File

@ -1423,6 +1423,9 @@ meta_kms_impl_device_atomic_initable_init (GInitable *initable,
GError **error)
{
MetaKmsImplDevice *impl_device = META_KMS_IMPL_DEVICE (initable);
MetaKmsDeviceCaps *caps = meta_kms_impl_device_get_caps (impl_device);
caps->supports_color_modes = TRUE;
if (!initable_parent_iface->init (initable, cancellable, error))
return FALSE;

View File

@ -231,7 +231,7 @@ meta_kms_impl_device_has_cursor_plane_for (MetaKmsImplDevice *impl_device,
return FALSE;
}
const MetaKmsDeviceCaps *
MetaKmsDeviceCaps *
meta_kms_impl_device_get_caps (MetaKmsImplDevice *impl_device)
{
MetaKmsImplDevicePrivate *priv =

View File

@ -38,6 +38,7 @@ typedef struct _MetaKmsDeviceCaps
gboolean prefers_shadow_buffer;
gboolean uses_monotonic_clock;
gboolean addfb2_modifiers;
gboolean supports_color_modes;
} MetaKmsDeviceCaps;
@ -122,7 +123,7 @@ GList * meta_kms_impl_device_peek_planes (MetaKmsImplDevice *impl_device);
gboolean meta_kms_impl_device_has_cursor_plane_for (MetaKmsImplDevice *impl_device,
MetaKmsCrtc *crtc);
const MetaKmsDeviceCaps * meta_kms_impl_device_get_caps (MetaKmsImplDevice *impl_device);
MetaKmsDeviceCaps * meta_kms_impl_device_get_caps (MetaKmsImplDevice *impl_device);
GList * meta_kms_impl_device_copy_fallback_modes (MetaKmsImplDevice *impl_device);

View File

@ -64,6 +64,7 @@ typedef enum _MetaKmsDeviceFlag
META_KMS_DEVICE_FLAG_FORCE_LEGACY = 1 << 6,
META_KMS_DEVICE_FLAG_DISABLE_CLIENT_MODIFIERS = 1 << 7,
META_KMS_DEVICE_FLAG_DISABLE_VRR = 1 << 8,
META_KMS_DEVICE_FLAG_SUPPORTS_COLOR_MODES = 1 << 9,
} MetaKmsDeviceFlag;
typedef enum _MetaKmsResourceChanges

View File

@ -367,6 +367,8 @@ meta_output_kms_new (MetaGpuKms *gpu_kms,
GError **error)
{
MetaGpu *gpu = META_GPU (gpu_kms);
MetaKmsDevice *device = meta_kms_connector_get_device (kms_connector);
MetaKmsDeviceFlag device_flags = meta_kms_device_get_flags (device);
uint32_t connector_id;
uint32_t gpu_id;
g_autoptr (MetaOutputInfo) output_info = NULL;
@ -453,7 +455,8 @@ meta_output_kms_new (MetaGpuKms *gpu_kms,
output_info->tile_info = connector_state->tile_info;
if (output_info->edid_info)
if ((device_flags & META_KMS_DEVICE_FLAG_SUPPORTS_COLOR_MODES) &&
output_info->edid_info)
{
struct di_supported_signal_colorimetry *edid_colorimetry =
&output_info->edid_info->colorimetry;
@ -467,7 +470,8 @@ meta_output_kms_new (MetaGpuKms *gpu_kms,
output_info->supported_color_spaces |= (1 << META_OUTPUT_COLORSPACE_BT2020);
}
if (connector_state->hdr.supported &&
if ((device_flags & META_KMS_DEVICE_FLAG_SUPPORTS_COLOR_MODES) &&
connector_state->hdr.supported &&
output_info->edid_info &&
output_info->edid_info->hdr_static_metadata.type1)
{