[qxl PATCH v2] Update drm properties correctly

Jonathon Jongsma jjongsma at redhat.com
Fri Nov 7 13:43:42 PST 2014


When connector properties got changed, those changes were not being
propagated to user-space. This pushes those chagnes up so that e.g. new
suggested_x|y properties can be used to help lay out multiple displays
properly. This code is based on similar code from the nouveau driver.
---

Changes since v1:
- refactor drmmode_prop_rec to add an 'index' member so that we don't need to
  iterate throught the property array later.

 src/qxl_drmmode.c | 48 +++++++++++++++++++++++++++++++++++++++++++++++-
 src/qxl_drmmode.h |  1 +
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/src/qxl_drmmode.c b/src/qxl_drmmode.c
index b7ea7d1..3c288f9 100644
--- a/src/qxl_drmmode.c
+++ b/src/qxl_drmmode.c
@@ -521,6 +521,7 @@ drmmode_output_create_resources(xf86OutputPtr output)
 	    drmModeFreeProperty(drmmode_prop);
 	    continue;
 	}
+	drmmode_output->props[j].index = i;
 	drmmode_output->props[j].mode_prop = drmmode_prop;
 	drmmode_output->props[j].value = mode_output->prop_values[i];
 	drmmode_output->num_props++;
@@ -640,7 +641,52 @@ drmmode_output_set_property(xf86OutputPtr output, Atom property,
 static Bool
 drmmode_output_get_property(xf86OutputPtr output, Atom property)
 {
-    return TRUE;
+    drmmode_output_private_ptr drmmode_output = output->driver_private;
+    drmmode_ptr drmmode = drmmode_output->drmmode;
+    uint32_t value;
+    int err, i;
+
+    if (output->scrn->vtSema) {
+	drmModeFreeConnector(drmmode_output->mode_output);
+	drmmode_output->mode_output =
+	    drmModeGetConnector(drmmode->fd, drmmode_output->output_id);
+    }
+
+    if (!drmmode_output->mode_output)
+	return FALSE;
+
+    for (i = 0; i < drmmode_output->num_props; i++) {
+	drmmode_prop_ptr p = &drmmode_output->props[i];
+	if (p->atoms[0] != property)
+	    continue;
+
+	value = drmmode_output->mode_output->prop_values[p->index];
+
+	if (p->mode_prop->flags & DRM_MODE_PROP_RANGE) {
+	    err = RRChangeOutputProperty(output->randr_output,
+					 property, XA_INTEGER, 32,
+					 PropModeReplace, 1, &value,
+					 FALSE, FALSE);
+
+	    return !err;
+	} else if (p->mode_prop->flags & DRM_MODE_PROP_ENUM) {
+	    int j;
+
+	    /* search for matching name string, then set its value down */
+	    for (j = 0; j < p->mode_prop->count_enums; j++) {
+		if (p->mode_prop->enums[j].value == value)
+		    break;
+	    }
+
+	    err = RRChangeOutputProperty(output->randr_output, property,
+					 XA_ATOM, 32, PropModeReplace, 1,
+					 &p->atoms[j+1], FALSE, FALSE);
+
+	    return !err;
+	}
+    }
+
+    return FALSE;
 }
 
 static const xf86OutputFuncsRec drmmode_output_funcs = {
diff --git a/src/qxl_drmmode.h b/src/qxl_drmmode.h
index 04752ec..392b1e2 100644
--- a/src/qxl_drmmode.h
+++ b/src/qxl_drmmode.h
@@ -69,6 +69,7 @@ typedef struct {
     uint64_t value;
     int num_atoms; /* if range prop, num_atoms == 1; if enum prop, num_atoms == num_enums + 1 */
     Atom *atoms;
+    int index; /* index within the kernel-size property array */
 } drmmode_prop_rec, *drmmode_prop_ptr;
 
 typedef struct {
-- 
1.9.3



More information about the xorg-devel mailing list