The `panel_power_saving` DRM property is an optional property that can be added to a connector by a driver. This property is for compositors to indicate intent of allowing policy for the driver to use power saving features that may compromise color fidelity. Signed-off-by: Mario Limonciello <mario.limonciello@xxxxxxx> --- drivers/gpu/drm/drm_connector.c | 36 +++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 1 + include/drm/drm_mode_config.h | 6 ++++++ include/uapi/drm/drm_mode.h | 4 ++++ 4 files changed, 47 insertions(+) diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 4d2df7f64dc5..ccf672c55e0c 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c @@ -961,6 +961,11 @@ static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = { { DRM_MODE_SCALE_ASPECT, "Full aspect" }, }; +static const struct drm_prop_enum_list drm_panel_power_saving_enum_list[] = { + { DRM_MODE_PANEL_POWER_SAVING_ALLOWED, "Allowed" }, + { DRM_MODE_PANEL_POWER_SAVING_FORBIDDEN, "Forbidden" }, +}; + static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = { { DRM_MODE_PICTURE_ASPECT_NONE, "Automatic" }, { DRM_MODE_PICTURE_ASPECT_4_3, "4:3" }, @@ -1963,6 +1968,37 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev) } EXPORT_SYMBOL(drm_mode_create_scaling_mode_property); +/** + * drm_mode_create_panel_power_saving_property - create panel power saving property + * @dev: DRM device + * + * Called by a driver the first time it's needed, must be attached to desired + * connectors. + * + * Atomic drivers should use drm_mode_create_panel_power_saving_property() + * instead to correctly assign &drm_connector_state.panel_power_saving + * in the atomic state. + * + * Returns: %0 + */ +int drm_mode_create_panel_power_saving_property(struct drm_device *dev) +{ + struct drm_property *panel_power_saving; + + if (dev->mode_config.panel_power_saving) + return 0; + + panel_power_saving = + drm_property_create_enum(dev, 0, "panel power saving", + drm_panel_power_saving_enum_list, + ARRAY_SIZE(drm_panel_power_saving_enum_list)); + + dev->mode_config.panel_power_saving = panel_power_saving; + + return 0; +} +EXPORT_SYMBOL(drm_mode_create_panel_power_saving_property); + /** * DOC: Variable refresh properties * diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h index fe88d7fc6b8f..4ea3f912c641 100644 --- a/include/drm/drm_connector.h +++ b/include/drm/drm_connector.h @@ -2025,6 +2025,7 @@ int drm_mode_create_dp_colorspace_property(struct drm_connector *connector, u32 supported_colorspaces); int drm_mode_create_content_type_property(struct drm_device *dev); int drm_mode_create_suggested_offset_properties(struct drm_device *dev); +int drm_mode_create_panel_power_saving_property(struct drm_device *dev); int drm_connector_set_path_property(struct drm_connector *connector, const char *path); diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h index 973119a9176b..099ad2d8c5c1 100644 --- a/include/drm/drm_mode_config.h +++ b/include/drm/drm_mode_config.h @@ -954,6 +954,12 @@ struct drm_mode_config { */ struct drm_atomic_state *suspend_state; + /** + * @panel_power_saving: DRM ENUM property for type of + * Panel Power Saving. + */ + struct drm_property *panel_power_saving; + const struct drm_mode_config_helper_funcs *helper_private; }; diff --git a/include/uapi/drm/drm_mode.h b/include/uapi/drm/drm_mode.h index 7040e7ea80c7..82e565cc76fb 100644 --- a/include/uapi/drm/drm_mode.h +++ b/include/uapi/drm/drm_mode.h @@ -152,6 +152,10 @@ extern "C" { #define DRM_MODE_SCALE_CENTER 2 /* Centered, no scaling */ #define DRM_MODE_SCALE_ASPECT 3 /* Full screen, preserve aspect */ +/* Panel power saving options */ +#define DRM_MODE_PANEL_POWER_SAVING_ALLOWED 0 /* Panel power savings features allowed */ +#define DRM_MODE_PANEL_POWER_SAVING_FORBIDDEN 1 /* Panel power savings features not allowed */ + /* Dithering mode options */ #define DRM_MODE_DITHERING_OFF 0 #define DRM_MODE_DITHERING_ON 1 -- 2.45.0