diff --git a/libweston/backend-drm/drm-internal.h b/libweston/backend-drm/drm-internal.h index b55061ab..29b68e38 100644 --- a/libweston/backend-drm/drm-internal.h +++ b/libweston/backend-drm/drm-internal.h @@ -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); diff --git a/libweston/backend-drm/kms.c b/libweston/backend-drm/kms.c index 4c942a3d..4cb242d3 100644 --- a/libweston/backend-drm/kms.c +++ b/libweston/backend-drm/kms.c @@ -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);