output: Check the EDID for HDR Static Metadata support

The existence of the KMS property just means that we can send an
InfoFrame but we also have to make sure the sink actually supports the
metadata type 1 and the selected transfer function.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2879>
This commit is contained in:
Sebastian Wick 2023-03-02 19:49:36 +01:00 committed by Marge Bot
parent 7ecdfaa78d
commit af714edafb
4 changed files with 38 additions and 5 deletions

View File

@ -2285,7 +2285,7 @@ meta_monitor_set_hdr_metadata (MetaMonitor *monitor,
{ {
MetaOutput *output = l->data; MetaOutput *output = l->data;
if (!meta_output_is_hdr_metadata_supported (output)) if (!meta_output_is_hdr_metadata_supported (output, metadata->eotf))
{ {
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED, g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
"HDR metadata is not supported by this monitor"); "HDR metadata is not supported by this monitor");

View File

@ -561,9 +561,39 @@ meta_output_peek_color_space (MetaOutput *output)
} }
gboolean gboolean
meta_output_is_hdr_metadata_supported (MetaOutput *output) meta_output_is_hdr_metadata_supported (MetaOutput *output,
MetaOutputHdrMetadataEOTF eotf)
{ {
MetaOutputClass *output_class = META_OUTPUT_GET_CLASS (output); MetaOutputClass *output_class = META_OUTPUT_GET_CLASS (output);
const MetaOutputInfo *output_info = meta_output_get_info (output);
MetaEdidTransferFunction tf = 0;
g_assert (output_info != NULL);
if (!output_info->edid_info)
return FALSE;
if ((output_info->edid_info->hdr_static_metadata.sm &
META_EDID_STATIC_METADATA_TYPE1) == 0)
return FALSE;
switch (eotf)
{
case META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR:
tf = META_EDID_TF_TRADITIONAL_GAMMA_SDR;
break;
case META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_HDR:
tf = META_EDID_TF_TRADITIONAL_GAMMA_HDR;
break;
case META_OUTPUT_HDR_METADATA_EOTF_PQ:
tf = META_EDID_TF_PQ;
break;
case META_OUTPUT_HDR_METADATA_EOTF_HLG:
tf = META_EDID_TF_HLG;
break;
}
if ((output_info->edid_info->hdr_static_metadata.tf & tf) == 0)
return FALSE;
if (!output_class->is_hdr_metadata_supported) if (!output_class->is_hdr_metadata_supported)
return FALSE; return FALSE;

View File

@ -254,7 +254,8 @@ void meta_output_set_color_space (MetaOutput *output,
MetaOutputColorspace meta_output_peek_color_space (MetaOutput *output); MetaOutputColorspace meta_output_peek_color_space (MetaOutput *output);
gboolean meta_output_is_hdr_metadata_supported (MetaOutput *output); gboolean meta_output_is_hdr_metadata_supported (MetaOutput *output,
MetaOutputHdrMetadataEOTF eotf);
void meta_output_set_hdr_metadata (MetaOutput *output, void meta_output_set_hdr_metadata (MetaOutput *output,
MetaOutputHdrMetadata *metadata); MetaOutputHdrMetadata *metadata);

View File

@ -2241,7 +2241,8 @@ meta_onscreen_native_invalidate (MetaOnscreenNative *onscreen_native)
if (meta_output_is_color_space_supported (onscreen_native->output, if (meta_output_is_color_space_supported (onscreen_native->output,
META_OUTPUT_COLORSPACE_DEFAULT)) META_OUTPUT_COLORSPACE_DEFAULT))
onscreen_native->is_color_space_invalid = TRUE; onscreen_native->is_color_space_invalid = TRUE;
if (meta_output_is_hdr_metadata_supported (onscreen_native->output)) if (meta_output_is_hdr_metadata_supported (onscreen_native->output,
META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR))
onscreen_native->is_hdr_metadata_invalid = TRUE; onscreen_native->is_hdr_metadata_invalid = TRUE;
} }
@ -2342,7 +2343,8 @@ meta_onscreen_native_new (MetaRendererNative *renderer_native,
onscreen_native); onscreen_native);
} }
if (meta_output_is_hdr_metadata_supported (output)) if (meta_output_is_hdr_metadata_supported (output,
META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR))
{ {
onscreen_native->is_hdr_metadata_invalid = TRUE; onscreen_native->is_hdr_metadata_invalid = TRUE;
onscreen_native->hdr_metadata_changed_handler_id = onscreen_native->hdr_metadata_changed_handler_id =