[PATCH i-g-t 01/43] igt_kms: Factor out a generic get_property() out of get_drm_plane_type()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Damien Lespiau <damien.lespiau@xxxxxxxxx>
---
 lib/igt_kms.c | 45 ++++++++++++++++++++++++++++++++-------------
 1 file changed, 32 insertions(+), 13 deletions(-)

diff --git a/lib/igt_kms.c b/lib/igt_kms.c
index 4a8c394..666b0d0 100644
--- a/lib/igt_kms.c
+++ b/lib/igt_kms.c
@@ -495,37 +495,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)
-- 
1.8.3.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux