[PATCH 1/3] modetest: introduce get_prop_info() for getting property id and type

Hyungwon Hwang human.hwang at samsung.com
Tue Aug 25 23:21:46 PDT 2015


Modetest gets the property name from user to set it. So the name must be
converted to its id. Until now, this is done in the set_property(). But to
support atomic modeset in modetest, this logic should be separated from the
fuction, because atomic modeset and legacy modeset use different IOCTLs.

Signed-off-by: Hyungwon Hwang <human.hwang at samsung.com>
---
 tests/modetest/modetest.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 43bd06f..b7f6d32 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -866,12 +866,11 @@ struct property_arg {
 	uint64_t value;
 };
 
-static void set_property(struct device *dev, struct property_arg *p)
+static int get_prop_info(struct resources *resources, struct property_arg *p,
+								char *obj_type)
 {
 	drmModeObjectProperties *props = NULL;
 	drmModePropertyRes **props_info = NULL;
-	const char *obj_type;
-	int ret;
 	int i;
 
 	p->obj_type = 0;
@@ -884,27 +883,27 @@ static void set_property(struct device *dev, struct property_arg *p)
 			if (obj->type->type##_id != p->obj_id)			\
 				continue;					\
 			p->obj_type = DRM_MODE_OBJECT_##Type;			\
-			obj_type = #Type;					\
+			obj_type = (char *)#Type;				\
 			props = obj->props;					\
 			props_info = obj->props_info;				\
 		}								\
 	} while(0)								\
 
-	find_object(dev->resources, res, crtc, CRTC);
+	find_object(resources, res, crtc, CRTC);
 	if (p->obj_type == 0)
-		find_object(dev->resources, res, connector, CONNECTOR);
+		find_object(resources, res, connector, CONNECTOR);
 	if (p->obj_type == 0)
-		find_object(dev->resources, plane_res, plane, PLANE);
+		find_object(resources, plane_res, plane, PLANE);
 	if (p->obj_type == 0) {
 		fprintf(stderr, "Object %i not found, can't set property\n",
 			p->obj_id);
-			return;
+			return -1;
 	}
 
 	if (!props) {
 		fprintf(stderr, "%s %i has no properties\n",
 			obj_type, p->obj_id);
-		return;
+		return -1;
 	}
 
 	for (i = 0; i < (int)props->count_props; ++i) {
@@ -917,11 +916,23 @@ static void set_property(struct device *dev, struct property_arg *p)
 	if (i == (int)props->count_props) {
 		fprintf(stderr, "%s %i has no %s property\n",
 			obj_type, p->obj_id, p->name);
-		return;
+		return -1;
 	}
 
 	p->prop_id = props->props[i];
 
+	return 0;
+}
+
+static void set_property(struct device *dev, struct property_arg *p)
+{
+	int ret;
+	char *obj_type = NULL;
+
+	ret = get_prop_info(dev->resources, p, obj_type);
+	if (ret < 0)
+		return;
+
 	ret = drmModeObjectSetProperty(dev->fd, p->obj_id, p->obj_type,
 				       p->prop_id, p->value);
 	if (ret < 0)
-- 
2.4.3



More information about the dri-devel mailing list