output: Move color space and hdr tf support to OutputInfo
Currently querying support for some output features is done partially through the OutputInfo and partially via KMS CRTC and Connector objects. Let's be consistent and use OutputInfo always which works with all backends and backend types. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3552>
This commit is contained in:
parent
fb7b9b0955
commit
a3a4de6c6b
@ -2246,8 +2246,9 @@ meta_monitor_set_color_space (MetaMonitor *monitor,
|
||||
for (l = priv->outputs; l; l = l->next)
|
||||
{
|
||||
MetaOutput *output = l->data;
|
||||
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
||||
|
||||
if (!meta_output_is_color_space_supported (output, color_space))
|
||||
if (!(output_info->supported_color_spaces & (1 << color_space)))
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"The color space is not supported by this monitor");
|
||||
@ -2276,8 +2277,9 @@ meta_monitor_set_hdr_metadata (MetaMonitor *monitor,
|
||||
for (l = priv->outputs; l; l = l->next)
|
||||
{
|
||||
MetaOutput *output = l->data;
|
||||
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
||||
|
||||
if (!meta_output_is_hdr_metadata_supported (output, metadata->eotf))
|
||||
if (!(output_info->supported_hdr_eotfs & (1 << metadata->eotf)))
|
||||
{
|
||||
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
|
||||
"HDR metadata is not supported by this monitor");
|
||||
|
@ -516,40 +516,6 @@ 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);
|
||||
|
||||
if (!output_class->is_color_space_supported)
|
||||
return FALSE;
|
||||
|
||||
return output_class->is_color_space_supported (output, color_space);
|
||||
}
|
||||
|
||||
void
|
||||
meta_output_set_color_space (MetaOutput *output,
|
||||
MetaOutputColorspace color_space)
|
||||
@ -584,47 +550,6 @@ meta_output_colorspace_get_name (MetaOutputColorspace color_space)
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
|
||||
gboolean
|
||||
meta_output_is_hdr_metadata_supported (MetaOutput *output,
|
||||
MetaOutputHdrMetadataEOTF eotf)
|
||||
{
|
||||
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)
|
||||
return FALSE;
|
||||
|
||||
return output_class->is_hdr_metadata_supported (output);
|
||||
}
|
||||
|
||||
void
|
||||
meta_output_set_hdr_metadata (MetaOutput *output,
|
||||
MetaOutputHdrMetadata *metadata)
|
||||
|
@ -164,6 +164,11 @@ typedef struct _MetaOutputInfo
|
||||
int suggested_y;
|
||||
|
||||
MetaTileInfo tile_info;
|
||||
|
||||
uint64_t supported_color_spaces;
|
||||
uint64_t supported_hdr_eotfs;
|
||||
|
||||
uint64_t supported_rgb_ranges;
|
||||
} MetaOutputInfo;
|
||||
|
||||
gboolean
|
||||
@ -189,9 +194,6 @@ 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);
|
||||
|
||||
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MetaOutputInfo, meta_output_info_unref)
|
||||
|
||||
#define META_TYPE_OUTPUT (meta_output_get_type ())
|
||||
@ -206,9 +208,6 @@ struct _MetaOutputClass
|
||||
gboolean (* set_privacy_screen_enabled) (MetaOutput *output,
|
||||
gboolean enabled,
|
||||
GError **error);
|
||||
gboolean (* is_color_space_supported) (MetaOutput *output,
|
||||
MetaOutputColorspace color_space);
|
||||
gboolean (* is_hdr_metadata_supported) (MetaOutput *output);
|
||||
};
|
||||
|
||||
META_EXPORT_TEST
|
||||
@ -255,17 +254,11 @@ gboolean meta_output_set_privacy_screen_enabled (MetaOutput *output,
|
||||
gboolean enabled,
|
||||
GError **error);
|
||||
|
||||
gboolean meta_output_is_color_space_supported (MetaOutput *output,
|
||||
MetaOutputColorspace color_space);
|
||||
|
||||
void meta_output_set_color_space (MetaOutput *output,
|
||||
MetaOutputColorspace color_space);
|
||||
|
||||
MetaOutputColorspace meta_output_peek_color_space (MetaOutput *output);
|
||||
|
||||
gboolean meta_output_is_hdr_metadata_supported (MetaOutput *output,
|
||||
MetaOutputHdrMetadataEOTF eotf);
|
||||
|
||||
void meta_output_set_hdr_metadata (MetaOutput *output,
|
||||
MetaOutputHdrMetadata *metadata);
|
||||
|
||||
|
@ -2579,15 +2579,18 @@ init_secondary_gpu_state (MetaRendererNative *renderer_native,
|
||||
void
|
||||
meta_onscreen_native_invalidate (MetaOnscreenNative *onscreen_native)
|
||||
{
|
||||
const MetaOutputInfo *output_info =
|
||||
meta_output_get_info (onscreen_native->output);
|
||||
|
||||
if (meta_crtc_get_gamma_lut_size (onscreen_native->crtc) > 0)
|
||||
onscreen_native->is_gamma_lut_invalid = TRUE;
|
||||
if (meta_output_is_privacy_screen_supported (onscreen_native->output))
|
||||
onscreen_native->is_privacy_screen_invalid = TRUE;
|
||||
if (meta_output_is_color_space_supported (onscreen_native->output,
|
||||
META_OUTPUT_COLORSPACE_DEFAULT))
|
||||
if (output_info->supported_color_spaces &
|
||||
(1 << META_OUTPUT_COLORSPACE_DEFAULT))
|
||||
onscreen_native->is_color_space_invalid = TRUE;
|
||||
if (meta_output_is_hdr_metadata_supported (onscreen_native->output,
|
||||
META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR))
|
||||
if (output_info->supported_hdr_eotfs &
|
||||
(1 << META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR))
|
||||
onscreen_native->is_hdr_metadata_invalid = TRUE;
|
||||
}
|
||||
|
||||
@ -2643,6 +2646,7 @@ meta_onscreen_native_new (MetaRendererNative *renderer_native,
|
||||
{
|
||||
MetaOnscreenNative *onscreen_native;
|
||||
CoglFramebufferDriverConfig driver_config;
|
||||
const MetaOutputInfo *output_info = meta_output_get_info (output);
|
||||
|
||||
driver_config = (CoglFramebufferDriverConfig) {
|
||||
.type = COGL_FRAMEBUFFER_DRIVER_TYPE_BACK,
|
||||
@ -2678,8 +2682,8 @@ meta_onscreen_native_new (MetaRendererNative *renderer_native,
|
||||
onscreen_native);
|
||||
}
|
||||
|
||||
if (meta_output_is_color_space_supported (output,
|
||||
META_OUTPUT_COLORSPACE_DEFAULT))
|
||||
if (output_info->supported_color_spaces &
|
||||
(1 << META_OUTPUT_COLORSPACE_DEFAULT))
|
||||
{
|
||||
onscreen_native->is_color_space_invalid = TRUE;
|
||||
onscreen_native->color_space_changed_handler_id =
|
||||
@ -2688,8 +2692,8 @@ meta_onscreen_native_new (MetaRendererNative *renderer_native,
|
||||
onscreen_native);
|
||||
}
|
||||
|
||||
if (meta_output_is_hdr_metadata_supported (output,
|
||||
META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR))
|
||||
if (output_info->supported_hdr_eotfs &
|
||||
(1 << META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR))
|
||||
{
|
||||
onscreen_native->is_hdr_metadata_invalid = TRUE;
|
||||
onscreen_native->hdr_metadata_changed_handler_id =
|
||||
|
@ -65,54 +65,6 @@ meta_output_kms_get_privacy_screen_state (MetaOutput *output)
|
||||
return connector_state->privacy_screen_state;
|
||||
}
|
||||
|
||||
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))
|
||||
{
|
||||
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)))
|
||||
{
|
||||
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;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
meta_output_kms_is_hdr_metadata_supported (MetaOutput *output)
|
||||
{
|
||||
MetaOutputKms *output_kms = META_OUTPUT_KMS (output);
|
||||
const MetaKmsConnectorState *connector_state;
|
||||
|
||||
connector_state =
|
||||
meta_kms_connector_get_current_state (output_kms->kms_connector);
|
||||
|
||||
return connector_state->hdr.supported;
|
||||
}
|
||||
|
||||
uint32_t
|
||||
meta_output_kms_get_connector_id (MetaOutputKms *output_kms)
|
||||
{
|
||||
@ -428,6 +380,50 @@ meta_output_kms_new (MetaGpuKms *gpu_kms,
|
||||
|
||||
output_info->tile_info = connector_state->tile_info;
|
||||
|
||||
if (output_info->edid_info)
|
||||
{
|
||||
MetaEdidColorimetry edid_colorimetry =
|
||||
output_info->edid_info->colorimetry;
|
||||
uint64_t connector_colorimetry = connector_state->colorspace.supported;
|
||||
|
||||
if (connector_colorimetry & (1 << META_OUTPUT_COLORSPACE_DEFAULT))
|
||||
output_info->supported_color_spaces |= (1 << META_OUTPUT_COLORSPACE_DEFAULT);
|
||||
|
||||
if ((edid_colorimetry & META_EDID_COLORIMETRY_BT2020RGB) &&
|
||||
(connector_colorimetry & (1 << META_OUTPUT_COLORSPACE_BT2020)))
|
||||
output_info->supported_color_spaces |= (1 << META_OUTPUT_COLORSPACE_BT2020);
|
||||
}
|
||||
|
||||
if (connector_state->hdr.supported &&
|
||||
output_info->edid_info &&
|
||||
(output_info->edid_info->hdr_static_metadata.sm &
|
||||
META_EDID_STATIC_METADATA_TYPE1))
|
||||
{
|
||||
MetaEdidTransferFunction edid_tf =
|
||||
output_info->edid_info->hdr_static_metadata.tf;
|
||||
|
||||
if (edid_tf & META_EDID_TF_TRADITIONAL_GAMMA_SDR)
|
||||
{
|
||||
output_info->supported_hdr_eotfs |=
|
||||
(1 << META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_SDR);
|
||||
}
|
||||
if (edid_tf & META_EDID_TF_TRADITIONAL_GAMMA_HDR)
|
||||
{
|
||||
output_info->supported_hdr_eotfs |=
|
||||
(1 << META_OUTPUT_HDR_METADATA_EOTF_TRADITIONAL_GAMMA_HDR);
|
||||
}
|
||||
if (edid_tf & META_EDID_TF_PQ)
|
||||
{
|
||||
output_info->supported_hdr_eotfs |=
|
||||
(1 << META_OUTPUT_HDR_METADATA_EOTF_PQ);
|
||||
}
|
||||
if (edid_tf & META_EDID_TF_HLG)
|
||||
{
|
||||
output_info->supported_hdr_eotfs |=
|
||||
(1 << META_OUTPUT_HDR_METADATA_EOTF_HLG);
|
||||
}
|
||||
}
|
||||
|
||||
output = g_object_new (META_TYPE_OUTPUT_KMS,
|
||||
"id", ((uint64_t) gpu_id << 32) | connector_id,
|
||||
"gpu", gpu,
|
||||
@ -486,10 +482,6 @@ meta_output_kms_class_init (MetaOutputKmsClass *klass)
|
||||
|
||||
output_class->get_privacy_screen_state =
|
||||
meta_output_kms_get_privacy_screen_state;
|
||||
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;
|
||||
|
||||
output_native_class->read_edid = meta_output_kms_read_edid;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user