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

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

 



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@xxxxxxxxxxx>
---
 tests/modetest/modetest.c | 29 ++++++++++++++++++++---------
 1 file changed, 20 insertions(+), 9 deletions(-)

diff --git a/tests/modetest/modetest.c b/tests/modetest/modetest.c
index 3b01918..08ecf58 100644
--- a/tests/modetest/modetest.c
+++ b/tests/modetest/modetest.c
@@ -894,12 +894,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,
+							const char *obj_type)
 {
 	drmModeObjectProperties *props = NULL;
 	drmModePropertyRes **props_info = NULL;
-	const char *obj_type;
-	int ret;
 	int i;

 	p->obj_type = 0;
@@ -918,21 +917,21 @@ static void set_property(struct device *dev, struct property_arg *p)
 		}								\
 	} 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) {
@@ -945,11 +944,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;
+	const 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

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux