From 9519a849670c6ef1ec8a974c6930eb32d0ea03f2 Mon Sep 17 00:00:00 2001 From: Sebastian Wick Date: Wed, 20 Apr 2022 21:43:28 +0200 Subject: [PATCH] backends/native: Define all KMS properties in PropTable we actually use Currently those properties are looked up manually or fixed values are used when they should be looked up. The following commits will actually make use of this. Part-of: --- .../native/meta-kms-connector-private.h | 52 ++++++ src/backends/native/meta-kms-connector.c | 162 ++++++++++++++++++ src/backends/native/meta-kms-impl-device.h | 18 +- src/backends/native/meta-kms-plane-private.h | 21 +++ src/backends/native/meta-kms-plane.c | 37 +++- 5 files changed, 287 insertions(+), 3 deletions(-) diff --git a/src/backends/native/meta-kms-connector-private.h b/src/backends/native/meta-kms-connector-private.h index b9a2e21bd..6ae8b18c3 100644 --- a/src/backends/native/meta-kms-connector-private.h +++ b/src/backends/native/meta-kms-connector-private.h @@ -31,9 +31,61 @@ typedef enum _MetaKmsConnectorProp META_KMS_CONNECTOR_PROP_UNDERSCAN_VBORDER, META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_SW_STATE, META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_HW_STATE, + META_KMS_CONNECTOR_PROP_EDID, + META_KMS_CONNECTOR_PROP_TILE, + META_KMS_CONNECTOR_PROP_SUGGESTED_X, + META_KMS_CONNECTOR_PROP_SUGGESTED_Y, + META_KMS_CONNECTOR_PROP_HOTPLUG_MODE_UPDATE, + META_KMS_CONNECTOR_PROP_SCALING_MODE, + META_KMS_CONNECTOR_PROP_PANEL_ORIENTATION, + META_KMS_CONNECTOR_PROP_NON_DESKTOP, META_KMS_CONNECTOR_N_PROPS } MetaKmsConnectorProp; +typedef enum _MetaKmsConnectorDpms +{ + META_KMS_CONNECTOR_DPMS_ON = 0, + META_KMS_CONNECTOR_DPMS_STANDBY, + META_KMS_CONNECTOR_DPMS_SUSPEND, + META_KMS_CONNECTOR_DPMS_OFF, + META_KMS_CONNECTOR_DPMS_N_PROPS +} MetaKmsConnectorDpms; + +typedef enum _MetaKmsConnectorUnderscan +{ + META_KMS_CONNECTOR_UNDERSCAN_OFF = 0, + META_KMS_CONNECTOR_UNDERSCAN_ON, + META_KMS_CONNECTOR_UNDERSCAN_AUTO, + META_KMS_CONNECTOR_UNDERSCAN_N_PROPS +} MetaKmsConnectorUnderscan; + +typedef enum _MetaKmsConnectorPrivacyScreen +{ + META_KMS_CONNECTOR_PRIVACY_SCREEN_ENABLED = 0, + META_KMS_CONNECTOR_PRIVACY_SCREEN_DISABLED, + META_KMS_CONNECTOR_PRIVACY_SCREEN_ENABLED_LOCKED, + META_KMS_CONNECTOR_PRIVACY_SCREEN_DISABLED_LOCKED, + META_KMS_CONNECTOR_PRIVACY_SCREEN_N_PROPS, +} MetaKmsConnectorPrivacyScreen; + +typedef enum _MetaKmsConnectorScalingMode +{ + META_KMS_CONNECTOR_SCALING_MODE_NONE = 0, + META_KMS_CONNECTOR_SCALING_MODE_FULL, + META_KMS_CONNECTOR_SCALING_MODE_CENTER, + META_KMS_CONNECTOR_SCALING_MODE_FULL_ASPECT, + META_KMS_CONNECTOR_SCALING_MODE_N_PROPS, +} MetaKmsConnectorScalingMode; + +typedef enum _MetaKmsConnectorPanelOrientation +{ + META_KMS_CONNECTOR_PANEL_ORIENTATION_NORMAL = 0, + META_KMS_CONNECTOR_PANEL_ORIENTATION_UPSIDE_DOWN, + META_KMS_CONNECTOR_PANEL_ORIENTATION_LEFT_SIDE_UP, + META_KMS_CONNECTOR_PANEL_ORIENTATION_RIGHT_SIDE_UP, + META_KMS_CONNECTOR_PANEL_ORIENTATION_N_PROPS, +} MetaKmsConnectorPanelOrientation; + uint32_t meta_kms_connector_get_prop_id (MetaKmsConnector *connector, MetaKmsConnectorProp prop); diff --git a/src/backends/native/meta-kms-connector.c b/src/backends/native/meta-kms-connector.c index b7550e12e..6804fb6d3 100644 --- a/src/backends/native/meta-kms-connector.c +++ b/src/backends/native/meta-kms-connector.c @@ -34,6 +34,12 @@ typedef struct _MetaKmsConnectorPropTable { MetaKmsProp props[META_KMS_CONNECTOR_N_PROPS]; + MetaKmsEnum dpms_enum[META_KMS_CONNECTOR_DPMS_N_PROPS]; + MetaKmsEnum underscan_enum[META_KMS_CONNECTOR_UNDERSCAN_N_PROPS]; + MetaKmsEnum privacy_screen_sw_enum[META_KMS_CONNECTOR_PRIVACY_SCREEN_N_PROPS]; + MetaKmsEnum privacy_screen_hw_enum[META_KMS_CONNECTOR_PRIVACY_SCREEN_N_PROPS]; + MetaKmsEnum scaling_mode_enum[META_KMS_CONNECTOR_SCALING_MODE_N_PROPS]; + MetaKmsEnum panel_orientation_enum[META_KMS_CONNECTOR_PANEL_ORIENTATION_N_PROPS]; } MetaKmsConnectorPropTable; struct _MetaKmsConnector @@ -853,11 +859,15 @@ init_properties (MetaKmsConnector *connector, { .name = "DPMS", .type = DRM_MODE_PROP_ENUM, + .enum_values = prop_table->dpms_enum, + .num_enum_values = META_KMS_CONNECTOR_DPMS_N_PROPS, }, [META_KMS_CONNECTOR_PROP_UNDERSCAN] = { .name = "underscan", .type = DRM_MODE_PROP_ENUM, + .enum_values = prop_table->underscan_enum, + .num_enum_values = META_KMS_CONNECTOR_UNDERSCAN_N_PROPS, }, [META_KMS_CONNECTOR_PROP_UNDERSCAN_HBORDER] = { @@ -873,11 +883,163 @@ init_properties (MetaKmsConnector *connector, { .name = "privacy-screen sw-state", .type = DRM_MODE_PROP_ENUM, + .enum_values = prop_table->privacy_screen_sw_enum, + .num_enum_values = META_KMS_CONNECTOR_PRIVACY_SCREEN_N_PROPS, }, [META_KMS_CONNECTOR_PROP_PRIVACY_SCREEN_HW_STATE] = { .name = "privacy-screen hw-state", .type = DRM_MODE_PROP_ENUM, + .enum_values = prop_table->privacy_screen_hw_enum, + .num_enum_values = META_KMS_CONNECTOR_PRIVACY_SCREEN_N_PROPS, + }, + [META_KMS_CONNECTOR_PROP_EDID] = + { + .name = "EDID", + .type = DRM_MODE_PROP_BLOB, + }, + [META_KMS_CONNECTOR_PROP_TILE] = + { + .name = "TILE", + .type = DRM_MODE_PROP_BLOB, + }, + [META_KMS_CONNECTOR_PROP_SUGGESTED_X] = + { + .name = "suggested X", + .type = DRM_MODE_PROP_RANGE, + }, + [META_KMS_CONNECTOR_PROP_SUGGESTED_Y] = + { + .name = "suggested Y", + .type = DRM_MODE_PROP_RANGE, + }, + [META_KMS_CONNECTOR_PROP_HOTPLUG_MODE_UPDATE] = + { + .name = "hotplug_mode_update", + .type = DRM_MODE_PROP_RANGE, + }, + [META_KMS_CONNECTOR_PROP_SCALING_MODE] = + { + .name = "scaling mode", + .type = DRM_MODE_PROP_ENUM, + .enum_values = prop_table->scaling_mode_enum, + .num_enum_values = META_KMS_CONNECTOR_SCALING_MODE_N_PROPS, + }, + [META_KMS_CONNECTOR_PROP_PANEL_ORIENTATION] = + { + .name = "panel orientation", + .type = DRM_MODE_PROP_ENUM, + .enum_values = prop_table->panel_orientation_enum, + .num_enum_values = META_KMS_CONNECTOR_PANEL_ORIENTATION_N_PROPS, + }, + [META_KMS_CONNECTOR_PROP_NON_DESKTOP] = + { + .name = "non-desktop", + .type = DRM_MODE_PROP_RANGE, + }, + }, + .dpms_enum = { + [META_KMS_CONNECTOR_DPMS_ON] = + { + .name = "On", + }, + [META_KMS_CONNECTOR_DPMS_STANDBY] = + { + .name = "Standby", + }, + [META_KMS_CONNECTOR_DPMS_SUSPEND] = + { + .name = "Suspend", + }, + [META_KMS_CONNECTOR_DPMS_OFF] = + { + .name = "Off", + }, + }, + .underscan_enum = { + [META_KMS_CONNECTOR_UNDERSCAN_OFF] = + { + .name = "off", + }, + [META_KMS_CONNECTOR_UNDERSCAN_ON] = + { + .name = "on", + }, + [META_KMS_CONNECTOR_UNDERSCAN_AUTO] = + { + .name = "auto", + }, + }, + .privacy_screen_sw_enum = { + [META_KMS_CONNECTOR_PRIVACY_SCREEN_ENABLED] = + { + .name = "Enabled", + }, + [META_KMS_CONNECTOR_PRIVACY_SCREEN_DISABLED] = + { + .name = "Disabled", + }, + [META_KMS_CONNECTOR_PRIVACY_SCREEN_ENABLED_LOCKED] = + { + .name = "Enabled-locked", + }, + [META_KMS_CONNECTOR_PRIVACY_SCREEN_DISABLED_LOCKED] = + { + .name = "Disabled-locked", + }, + }, + .privacy_screen_hw_enum = { + [META_KMS_CONNECTOR_PRIVACY_SCREEN_ENABLED] = + { + .name = "Enabled", + }, + [META_KMS_CONNECTOR_PRIVACY_SCREEN_DISABLED] = + { + .name = "Disabled", + }, + [META_KMS_CONNECTOR_PRIVACY_SCREEN_ENABLED_LOCKED] = + { + .name = "Enabled-locked", + }, + [META_KMS_CONNECTOR_PRIVACY_SCREEN_DISABLED_LOCKED] = + { + .name = "Disabled-locked", + }, + }, + .scaling_mode_enum = { + [META_KMS_CONNECTOR_SCALING_MODE_NONE] = + { + .name = "None", + }, + [META_KMS_CONNECTOR_SCALING_MODE_FULL] = + { + .name = "Full", + }, + [META_KMS_CONNECTOR_SCALING_MODE_CENTER] = + { + .name = "Center", + }, + [META_KMS_CONNECTOR_SCALING_MODE_FULL_ASPECT] = + { + .name = "Full aspect", + }, + }, + .panel_orientation_enum = { + [META_KMS_CONNECTOR_PANEL_ORIENTATION_NORMAL] = + { + .name = "Normal", + }, + [META_KMS_CONNECTOR_PANEL_ORIENTATION_UPSIDE_DOWN] = + { + .name = "Upside Down", + }, + [META_KMS_CONNECTOR_PANEL_ORIENTATION_LEFT_SIDE_UP] = + { + .name = "Left Side Up", + }, + [META_KMS_CONNECTOR_PANEL_ORIENTATION_RIGHT_SIDE_UP] = + { + .name = "Right Side Up", }, } }; diff --git a/src/backends/native/meta-kms-impl-device.h b/src/backends/native/meta-kms-impl-device.h index 286c2700a..f50b1b637 100644 --- a/src/backends/native/meta-kms-impl-device.h +++ b/src/backends/native/meta-kms-impl-device.h @@ -43,6 +43,15 @@ typedef struct _MetaKmsDeviceCaps gboolean addfb2_modifiers; } MetaKmsDeviceCaps; + +typedef struct _MetaKmsEnum +{ + const char *name; + gboolean valid; + uint64_t value; + uint64_t bitmask; +} MetaKmsEnum; + typedef struct _MetaKmsProp MetaKmsProp; struct _MetaKmsProp @@ -50,13 +59,18 @@ struct _MetaKmsProp const char *name; uint32_t type; MetaKmsPropType internal_type; + + unsigned int num_enum_values; + MetaKmsEnum *enum_values; + + uint32_t prop_id; + uint64_t value; + void (* parse) (MetaKmsImplDevice *impl_device, MetaKmsProp *prop, drmModePropertyPtr drm_prop, uint64_t value, gpointer user_data); - - uint32_t prop_id; }; #define META_TYPE_KMS_IMPL_DEVICE (meta_kms_impl_device_get_type ()) diff --git a/src/backends/native/meta-kms-plane-private.h b/src/backends/native/meta-kms-plane-private.h index f735c8da8..215a4754f 100644 --- a/src/backends/native/meta-kms-plane-private.h +++ b/src/backends/native/meta-kms-plane-private.h @@ -45,6 +45,27 @@ typedef enum _MetaKmsPlaneProp META_KMS_PLANE_N_PROPS } MetaKmsPlaneProp; +typedef enum _MetaKmsPlaneRotationBit +{ + META_KMS_PLANE_ROTATION_BIT_ROTATE_0 = 0, + META_KMS_PLANE_ROTATION_BIT_ROTATE_90, + META_KMS_PLANE_ROTATION_BIT_ROTATE_180, + META_KMS_PLANE_ROTATION_BIT_ROTATE_270, + META_KMS_PLANE_ROTATION_BIT_REFLECT_X, + META_KMS_PLANE_ROTATION_BIT_REFLECT_Y, + META_KMS_PLANE_ROTATION_BIT_N_PROPS, +} MetaKmsPlaneRotationBit; + +typedef enum _MetaKmsPlaneRotation +{ + META_KMS_PLANE_ROTATION_ROTATE_0 = (1 << 0), + META_KMS_PLANE_ROTATION_ROTATE_90 = (1 << 1), + META_KMS_PLANE_ROTATION_ROTATE_180 = (1 << 2), + META_KMS_PLANE_ROTATION_ROTATE_270 = (1 << 3), + META_KMS_PLANE_ROTATION_REFLECT_X = (1 << 4), + META_KMS_PLANE_ROTATION_REFLECT_Y = (1 << 5), +} MetaKmsPlaneRotation; + MetaKmsPlane * meta_kms_plane_new (MetaKmsPlaneType type, MetaKmsImplDevice *impl_device, drmModePlane *drm_plane, diff --git a/src/backends/native/meta-kms-plane.c b/src/backends/native/meta-kms-plane.c index 3cb58764f..6742ccd11 100644 --- a/src/backends/native/meta-kms-plane.c +++ b/src/backends/native/meta-kms-plane.c @@ -33,6 +33,7 @@ typedef struct _MetaKmsPlanePropTable { MetaKmsProp props[META_KMS_PLANE_N_PROPS]; + MetaKmsEnum rotation_bitmask[META_KMS_PLANE_ROTATION_BIT_N_PROPS]; } MetaKmsPlanePropTable; struct _MetaKmsPlane @@ -384,6 +385,8 @@ init_properties (MetaKmsPlane *plane, { .name = "rotation", .type = DRM_MODE_PROP_BITMASK, + .enum_values = prop_table->rotation_bitmask, + .num_enum_values = META_KMS_PLANE_ROTATION_BIT_N_PROPS, .parse = parse_rotations, }, [META_KMS_PLANE_PROP_IN_FORMATS] = @@ -451,7 +454,39 @@ init_properties (MetaKmsPlane *plane, .name = "FB_DAMAGE_CLIPS", .type = DRM_MODE_PROP_BLOB, }, - } + }, + .rotation_bitmask = { + [META_KMS_PLANE_ROTATION_BIT_ROTATE_0] = + { + .name = "rotate-0", + .bitmask = META_KMS_PLANE_ROTATION_ROTATE_0, + }, + [META_KMS_PLANE_ROTATION_BIT_ROTATE_90] = + { + .name = "rotate-90", + .bitmask = META_KMS_PLANE_ROTATION_ROTATE_90, + }, + [META_KMS_PLANE_ROTATION_BIT_ROTATE_180] = + { + .name = "rotate-180", + .bitmask = META_KMS_PLANE_ROTATION_ROTATE_180, + }, + [META_KMS_PLANE_ROTATION_BIT_ROTATE_270] = + { + .name = "rotate-270", + .bitmask = META_KMS_PLANE_ROTATION_ROTATE_270, + }, + [META_KMS_PLANE_ROTATION_BIT_REFLECT_X] = + { + .name = "reflect-x", + .bitmask = META_KMS_PLANE_ROTATION_REFLECT_X, + }, + [META_KMS_PLANE_ROTATION_BIT_REFLECT_Y] = + { + .name = "reflect-y", + .bitmask = META_KMS_PLANE_ROTATION_REFLECT_Y, + }, + }, }; meta_kms_impl_device_init_prop_table (impl_device,