Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 960cd9d4 authored by Daniel Vetter's avatar Daniel Vetter
Browse files

drm: Add standardized boolean props



Not a new type exposed to userspace, just a standard way to create
them since between range, bitmask and enum there's 3 different ways to
pull out a boolean prop.

Also add the kerneldoc for the recently added new prop types, which
Rob forgot all about.

v2: Fixup kerneldoc, spotted by Rob.

Cc: Rob Clark <robdclark@gmail.com>
Reviewed-by: default avatarRob Clark <robdclark@gmail.com>
Reviewed-by: default avatarThierry Reding <treding@nvidia.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@intel.com>
parent 6a425c2a
Loading
Loading
Loading
Loading
+63 −3
Original line number Original line Diff line number Diff line
@@ -3810,7 +3810,7 @@ static struct drm_property *property_create_range(struct drm_device *dev,
}
}


/**
/**
 * drm_property_create_range - create a new ranged property type
 * drm_property_create_range - create a new unsigned ranged property type
 * @dev: drm device
 * @dev: drm device
 * @flags: flags specifying the property type
 * @flags: flags specifying the property type
 * @name: name of the property
 * @name: name of the property
@@ -3821,8 +3821,8 @@ static struct drm_property *property_create_range(struct drm_device *dev,
 * object with drm_object_attach_property. The returned property object must be
 * object with drm_object_attach_property. The returned property object must be
 * freed with drm_property_destroy.
 * freed with drm_property_destroy.
 *
 *
 * Userspace is allowed to set any integer value in the (min, max) range
 * Userspace is allowed to set any unsigned integer value in the (min, max)
 * inclusive.
 * range inclusive.
 *
 *
 * Returns:
 * Returns:
 * A pointer to the newly created property on success, NULL on failure.
 * A pointer to the newly created property on success, NULL on failure.
@@ -3836,6 +3836,24 @@ struct drm_property *drm_property_create_range(struct drm_device *dev, int flags
}
}
EXPORT_SYMBOL(drm_property_create_range);
EXPORT_SYMBOL(drm_property_create_range);


/**
 * drm_property_create_signed_range - create a new signed ranged property type
 * @dev: drm device
 * @flags: flags specifying the property type
 * @name: name of the property
 * @min: minimum value of the property
 * @max: maximum value of the property
 *
 * This creates a new generic drm property which can then be attached to a drm
 * object with drm_object_attach_property. The returned property object must be
 * freed with drm_property_destroy.
 *
 * Userspace is allowed to set any signed integer value in the (min, max)
 * range inclusive.
 *
 * Returns:
 * A pointer to the newly created property on success, NULL on failure.
 */
struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
					 int flags, const char *name,
					 int flags, const char *name,
					 int64_t min, int64_t max)
					 int64_t min, int64_t max)
@@ -3845,6 +3863,23 @@ struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
}
}
EXPORT_SYMBOL(drm_property_create_signed_range);
EXPORT_SYMBOL(drm_property_create_signed_range);


/**
 * drm_property_create_object - create a new object property type
 * @dev: drm device
 * @flags: flags specifying the property type
 * @name: name of the property
 * @type: object type from DRM_MODE_OBJECT_* defines
 *
 * This creates a new generic drm property which can then be attached to a drm
 * object with drm_object_attach_property. The returned property object must be
 * freed with drm_property_destroy.
 *
 * Userspace is only allowed to set this to any property value of the given
 * @type. Only useful for atomic properties, which is enforced.
 *
 * Returns:
 * A pointer to the newly created property on success, NULL on failure.
 */
struct drm_property *drm_property_create_object(struct drm_device *dev,
struct drm_property *drm_property_create_object(struct drm_device *dev,
					 int flags, const char *name, uint32_t type)
					 int flags, const char *name, uint32_t type)
{
{
@@ -3852,6 +3887,9 @@ struct drm_property *drm_property_create_object(struct drm_device *dev,


	flags |= DRM_MODE_PROP_OBJECT;
	flags |= DRM_MODE_PROP_OBJECT;


	if (WARN_ON(!(flags & DRM_MODE_PROP_ATOMIC)))
		return NULL;

	property = drm_property_create(dev, flags, name, 1);
	property = drm_property_create(dev, flags, name, 1);
	if (!property)
	if (!property)
		return NULL;
		return NULL;
@@ -3862,6 +3900,28 @@ struct drm_property *drm_property_create_object(struct drm_device *dev,
}
}
EXPORT_SYMBOL(drm_property_create_object);
EXPORT_SYMBOL(drm_property_create_object);


/**
 * drm_property_create_bool - create a new boolean property type
 * @dev: drm device
 * @flags: flags specifying the property type
 * @name: name of the property
 *
 * This creates a new generic drm property which can then be attached to a drm
 * object with drm_object_attach_property. The returned property object must be
 * freed with drm_property_destroy.
 *
 * This is implemented as a ranged property with only {0, 1} as valid values.
 *
 * Returns:
 * A pointer to the newly created property on success, NULL on failure.
 */
struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags,
					 const char *name)
{
	return drm_property_create_range(dev, flags, name, 0, 1);
}
EXPORT_SYMBOL(drm_property_create_bool);

/**
/**
 * drm_property_add_enum - add a possible value to an enumeration property
 * drm_property_add_enum - add a possible value to an enumeration property
 * @property: enumeration property to change
 * @property: enumeration property to change
+2 −0
Original line number Original line Diff line number Diff line
@@ -1345,6 +1345,8 @@ struct drm_property *drm_property_create_signed_range(struct drm_device *dev,
					 int64_t min, int64_t max);
					 int64_t min, int64_t max);
struct drm_property *drm_property_create_object(struct drm_device *dev,
struct drm_property *drm_property_create_object(struct drm_device *dev,
					 int flags, const char *name, uint32_t type);
					 int flags, const char *name, uint32_t type);
struct drm_property *drm_property_create_bool(struct drm_device *dev, int flags,
					 const char *name);
extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
extern void drm_property_destroy(struct drm_device *dev, struct drm_property *property);
extern int drm_property_add_enum(struct drm_property *property, int index,
extern int drm_property_add_enum(struct drm_property *property, int index,
				 uint64_t value, const char *name);
				 uint64_t value, const char *name);