backend-drm: Teach drm_property_info_populate() to retrieve range values

Useful for zpos range values.

Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
Suggested-by: Daniel Stone <daniel.stone@collabora.com>
dev
Marius Vlad 5 years ago committed by Daniel Stone
parent 2cb926c558
commit 1accffe053
  1. 6
      libweston/backend-drm/drm-internal.h
  2. 45
      libweston/backend-drm/kms.c

@ -144,8 +144,11 @@ struct drm_property_enum_info {
struct drm_property_info {
const char *name; /**< name as string (static, not freed) */
uint32_t prop_id; /**< KMS property object ID */
uint32_t flags;
unsigned int num_enum_values; /**< number of enum values */
struct drm_property_enum_info *enum_values; /**< array of enum values */
unsigned int num_range_values;
uint64_t range_values[2];
};
/**
@ -579,6 +582,9 @@ uint64_t
drm_property_get_value(struct drm_property_info *info,
const drmModeObjectProperties *props,
uint64_t def);
uint64_t *
drm_property_get_range_values(struct drm_property_info *info,
const drmModeObjectProperties *props);
int
drm_plane_populate_formats(struct drm_plane *plane, const drmModePlane *kplane,
const drmModeObjectProperties *props);

@ -202,6 +202,42 @@ drm_property_get_value(struct drm_property_info *info,
return def;
}
/**
* Get the current range values of a KMS property
*
* Given a drmModeObjectGetProperties return, as well as the drm_property_info
* for the target property, return the current range values of that property,
*
* If the property is not present, or there's no it is not a prop range then
* NULL will be returned.
*
* @param info Internal structure for property to look up
* @param props Raw KMS properties for the target object
*/
uint64_t *
drm_property_get_range_values(struct drm_property_info *info,
const drmModeObjectProperties *props)
{
unsigned int i;
if (info->prop_id == 0)
return NULL;
for (i = 0; i < props->count_props; i++) {
if (props->props[i] != info->prop_id)
continue;
if (!(info->flags & DRM_MODE_PROP_RANGE) &&
!(info->flags & DRM_MODE_PROP_SIGNED_RANGE))
continue;
return info->range_values;
}
return NULL;
}
/**
* Cache DRM property values
*
@ -294,6 +330,15 @@ drm_property_info_populate(struct drm_backend *b,
}
info[j].prop_id = props->props[i];
info[j].flags = prop->flags;
if (prop->flags & DRM_MODE_PROP_RANGE ||
prop->flags & DRM_MODE_PROP_SIGNED_RANGE) {
info[j].num_range_values = prop->count_values;
for (int i = 0; i < prop->count_values; i++)
info[j].range_values[i] = prop->values[i];
}
if (info[j].num_enum_values == 0) {
drmModeFreeProperty(prop);

Loading…
Cancel
Save