diff options
author | Damien Lespiau <damien.lespiau@intel.com> | 2014-07-08 14:34:16 +0100 |
---|---|---|
committer | Damien Lespiau <damien.lespiau@intel.com> | 2014-07-11 15:12:21 +0100 |
commit | 33842d594044f13d3079d961df2894921be10cc5 (patch) | |
tree | 4f8135913384633619c8fbf1951796b2c569f831 /lib | |
parent | bebcb582fc40901a2aea4ab43fef3e273ad3b074 (diff) |
igt_kms: Factor out a generic get_property() out of get_drm_plane_type()
Signed-off-by: Damien Lespiau <damien.lespiau@intel.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/igt_kms.c | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 0c1143f1..84f29983 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -599,37 +599,56 @@ static void igt_output_refresh(igt_output_t *output) display->pipes_in_use |= 1 << output->config.pipe; } -/* - * Walk a plane's property list to determine its type. If we don't - * find a type property, then the kernel doesn't support universal - * planes and we know the plane is an overlay/sprite. - */ -static int get_drm_plane_type(igt_display_t *display, uint32_t plane_id) +static bool +get_property(igt_display_t *display, + uint32_t object_id, uint32_t object_type, const char *name, + uint32_t *prop_id /* out */, uint64_t *value /* out */) { drmModeObjectPropertiesPtr proplist; drmModePropertyPtr prop = NULL; - int type = DRM_PLANE_TYPE_OVERLAY; + bool found = false; int i; proplist = drmModeObjectGetProperties(display->drm_fd, - plane_id, - DRM_MODE_OBJECT_PLANE); + object_id, object_type); for (i = 0; i < proplist->count_props; i++) { drmModeFreeProperty(prop); prop = drmModeGetProperty(display->drm_fd, proplist->props[i]); if (!prop) continue; - if (strcmp(prop->name, "type") == 0) { - type = proplist->prop_values[i]; - break; + if (strcmp(prop->name, name) == 0) { + found = true; + if (prop_id) + *prop_id = proplist->props[i]; + if (value) + *value = proplist->prop_values[i]; + goto out; } } +out: drmModeFreeProperty(prop); drmModeFreeObjectProperties(proplist); + return found; +} + +/* + * Walk a plane's property list to determine its type. If we don't + * find a type property, then the kernel doesn't support universal + * planes and we know the plane is an overlay/sprite. + */ +static int get_drm_plane_type(igt_display_t *display, uint32_t plane_id) +{ + uint64_t value; + bool has_prop; + + has_prop = get_property(display, plane_id, DRM_MODE_OBJECT_PLANE, + "type", NULL /* prop_id */, &value); + if (has_prop) + return (int)value; - return type; + return DRM_PLANE_TYPE_OVERLAY; } void igt_display_init(igt_display_t *display, int drm_fd) |