aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_connector.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gpu/drm/drm_connector.c')
-rw-r--r--drivers/gpu/drm/drm_connector.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 9f847615ac74..5cd61aff7857 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -941,6 +941,10 @@ EXPORT_SYMBOL(drm_mode_create_tv_properties);
941 * 941 *
942 * Called by a driver the first time it's needed, must be attached to desired 942 * Called by a driver the first time it's needed, must be attached to desired
943 * connectors. 943 * connectors.
944 *
945 * Atomic drivers should use drm_connector_attach_scaling_mode_property()
946 * instead to correctly assign &drm_connector_state.picture_aspect_ratio
947 * in the atomic state.
944 */ 948 */
945int drm_mode_create_scaling_mode_property(struct drm_device *dev) 949int drm_mode_create_scaling_mode_property(struct drm_device *dev)
946{ 950{
@@ -961,6 +965,66 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
961EXPORT_SYMBOL(drm_mode_create_scaling_mode_property); 965EXPORT_SYMBOL(drm_mode_create_scaling_mode_property);
962 966
963/** 967/**
968 * drm_connector_attach_scaling_mode_property - attach atomic scaling mode property
969 * @connector: connector to attach scaling mode property on.
970 * @scaling_mode_mask: or'ed mask of BIT(%DRM_MODE_SCALE_\*).
971 *
972 * This is used to add support for scaling mode to atomic drivers.
973 * The scaling mode will be set to &drm_connector_state.picture_aspect_ratio
974 * and can be used from &drm_connector_helper_funcs->atomic_check for validation.
975 *
976 * This is the atomic version of drm_mode_create_scaling_mode_property().
977 *
978 * Returns:
979 * Zero on success, negative errno on failure.
980 */
981int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
982 u32 scaling_mode_mask)
983{
984 struct drm_device *dev = connector->dev;
985 struct drm_property *scaling_mode_property;
986 int i, j = 0;
987 const unsigned valid_scaling_mode_mask =
988 (1U << ARRAY_SIZE(drm_scaling_mode_enum_list)) - 1;
989
990 if (WARN_ON(hweight32(scaling_mode_mask) < 2 ||
991 scaling_mode_mask & ~valid_scaling_mode_mask))
992 return -EINVAL;
993
994 scaling_mode_property =
995 drm_property_create(dev, DRM_MODE_PROP_ENUM, "scaling mode",
996 hweight32(scaling_mode_mask));
997
998 if (!scaling_mode_property)
999 return -ENOMEM;
1000
1001 for (i = 0; i < ARRAY_SIZE(drm_scaling_mode_enum_list); i++) {
1002 int ret;
1003
1004 if (!(BIT(i) & scaling_mode_mask))
1005 continue;
1006
1007 ret = drm_property_add_enum(scaling_mode_property, j++,
1008 drm_scaling_mode_enum_list[i].type,
1009 drm_scaling_mode_enum_list[i].name);
1010
1011 if (ret) {
1012 drm_property_destroy(dev, scaling_mode_property);
1013
1014 return ret;
1015 }
1016 }
1017
1018 drm_object_attach_property(&connector->base,
1019 scaling_mode_property, 0);
1020
1021 connector->scaling_mode_property = scaling_mode_property;
1022
1023 return 0;
1024}
1025EXPORT_SYMBOL(drm_connector_attach_scaling_mode_property);
1026
1027/**
964 * drm_mode_create_aspect_ratio_property - create aspect ratio property 1028 * drm_mode_create_aspect_ratio_property - create aspect ratio property
965 * @dev: DRM device 1029 * @dev: DRM device
966 * 1030 *