kms-connector: Add "max bpc" property

This limits the bits-per-channel colour depth of the signal that
the connector is allowed to output.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2412>
This commit is contained in:
Daniel van Vugt 2022-05-13 16:20:57 +08:00 committed by Marge Bot
parent f765437410
commit 33ee155630
3 changed files with 36 additions and 0 deletions

View File

@ -39,6 +39,7 @@ typedef enum _MetaKmsConnectorProp
META_KMS_CONNECTOR_PROP_SCALING_MODE, META_KMS_CONNECTOR_PROP_SCALING_MODE,
META_KMS_CONNECTOR_PROP_PANEL_ORIENTATION, META_KMS_CONNECTOR_PROP_PANEL_ORIENTATION,
META_KMS_CONNECTOR_PROP_NON_DESKTOP, META_KMS_CONNECTOR_PROP_NON_DESKTOP,
META_KMS_CONNECTOR_PROP_MAX_BPC,
META_KMS_CONNECTOR_N_PROPS META_KMS_CONNECTOR_N_PROPS
} MetaKmsConnectorProp; } MetaKmsConnectorProp;

View File

@ -190,6 +190,19 @@ has_privacy_screen_software_toggle (MetaKmsConnector *connector)
META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_SW_STATE) != 0; META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_SW_STATE) != 0;
} }
const MetaKmsRange *
meta_kms_connector_get_max_bpc (MetaKmsConnector *connector)
{
const MetaKmsRange *range = NULL;
if (connector->current_state &&
meta_kms_connector_get_prop_id (connector,
META_KMS_CONNECTOR_PROP_MAX_BPC))
range = &connector->current_state->max_bpc;
return range;
}
static void static void
sync_fd_held (MetaKmsConnector *connector, sync_fd_held (MetaKmsConnector *connector,
MetaKmsImplDevice *impl_device) MetaKmsImplDevice *impl_device)
@ -308,6 +321,14 @@ state_set_properties (MetaKmsConnectorState *state,
prop = &props[META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_HW_STATE]; prop = &props[META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_HW_STATE];
if (prop->prop_id) if (prop->prop_id)
set_privacy_screen (state, connector, prop); set_privacy_screen (state, connector, prop);
prop = &props[META_KMS_CONNECTOR_PROP_MAX_BPC];
if (prop->prop_id)
{
state->max_bpc.value = prop->value;
state->max_bpc.min_value = prop->range_min;
state->max_bpc.max_value = prop->range_max;
}
} }
static CoglSubpixelOrder static CoglSubpixelOrder
@ -622,6 +643,11 @@ meta_kms_connector_state_changes (MetaKmsConnectorState *state,
if (!kms_modes_equal (state->modes, new_state->modes)) if (!kms_modes_equal (state->modes, new_state->modes))
return META_KMS_RESOURCE_CHANGE_FULL; return META_KMS_RESOURCE_CHANGE_FULL;
if (state->max_bpc.value != new_state->max_bpc.value ||
state->max_bpc.min_value != new_state->max_bpc.min_value ||
state->max_bpc.max_value != new_state->max_bpc.max_value)
return META_KMS_RESOURCE_CHANGE_FULL;
if (state->privacy_screen_state != new_state->privacy_screen_state) if (state->privacy_screen_state != new_state->privacy_screen_state)
return META_KMS_RESOURCE_CHANGE_PRIVACY_SCREEN; return META_KMS_RESOURCE_CHANGE_PRIVACY_SCREEN;
@ -940,6 +966,11 @@ init_properties (MetaKmsConnector *connector,
.name = "non-desktop", .name = "non-desktop",
.type = DRM_MODE_PROP_RANGE, .type = DRM_MODE_PROP_RANGE,
}, },
[META_KMS_CONNECTOR_PROP_MAX_BPC] =
{
.name = "max bpc",
.type = DRM_MODE_PROP_RANGE,
},
}, },
.dpms_enum = { .dpms_enum = {
[META_KMS_CONNECTOR_DPMS_ON] = [META_KMS_CONNECTOR_DPMS_ON] =

View File

@ -59,6 +59,8 @@ typedef struct _MetaKmsConnectorState
gboolean hotplug_mode_update; gboolean hotplug_mode_update;
MetaMonitorTransform panel_orientation_transform; MetaMonitorTransform panel_orientation_transform;
MetaKmsRange max_bpc;
} MetaKmsConnectorState; } MetaKmsConnectorState;
META_EXPORT_TEST META_EXPORT_TEST
@ -83,4 +85,6 @@ gboolean meta_kms_connector_is_underscanning_supported (MetaKmsConnector *connec
gboolean meta_kms_connector_is_privacy_screen_supported (MetaKmsConnector *connector); gboolean meta_kms_connector_is_privacy_screen_supported (MetaKmsConnector *connector);
const MetaKmsRange * meta_kms_connector_get_max_bpc (MetaKmsConnector *connector);
#endif /* META_KMS_CONNECTOR_H */ #endif /* META_KMS_CONNECTOR_H */