[Nouveau] [PATCH 1/2] nouveau/mode: split out create_ranged_atom

Dave Airlie airlied at gmail.com
Wed Jun 5 18:35:00 PDT 2013


From: Dave Airlie <airlied at redhat.com>

This is preperation for the backlight support code.

Signed-off-by: Dave Airlie <airlied at redhat.com>
---
 src/drmmode_display.c | 54 ++++++++++++++++++++++++++++++++-------------------
 1 file changed, 34 insertions(+), 20 deletions(-)

diff --git a/src/drmmode_display.c b/src/drmmode_display.c
index 6033a6d..ad7bc1f 100644
--- a/src/drmmode_display.c
+++ b/src/drmmode_display.c
@@ -767,6 +767,33 @@ drmmode_property_ignore(drmModePropertyPtr prop)
 }
 
 static void
+nouveau_create_ranged_atom(xf86OutputPtr output, Atom *atom,
+		   const char *name, INT32 min, INT32 max,
+		   uint64_t value, Bool immutable)
+{
+    int err;
+    INT32 atom_range[2];
+
+    atom_range[0] = min;
+    atom_range[1] = max;
+
+    *atom = MakeAtom(name, strlen(name), TRUE);
+    err = RRConfigureOutputProperty(output->randr_output, *atom,
+				    FALSE, TRUE, immutable,
+				    2, atom_range);
+    if (err != 0) {
+	xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+		   "RRConfigureOutputProperty error, %d\n", err);
+    }
+    err = RRChangeOutputProperty(output->randr_output, *atom,
+				 XA_INTEGER, 32, PropModeReplace, 1, &value, FALSE, TRUE);
+    if (err != 0) {
+	xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
+		   "RRChangeOutputProperty error, %d\n", err);
+    }
+}
+
+static void
 drmmode_output_create_resources(xf86OutputPtr output)
 {
 	drmmode_output_private_ptr drmmode_output = output->driver_private;
@@ -800,30 +827,17 @@ drmmode_output_create_resources(xf86OutputPtr output)
 		value = drmmode_output->mode_output->prop_values[p->index];
 
 		if (drmmode_prop->flags & DRM_MODE_PROP_RANGE) {
-			INT32 range[2];
-
 			p->num_atoms = 1;
 			p->atoms = calloc(p->num_atoms, sizeof(Atom));
 			if (!p->atoms)
 				continue;
-			p->atoms[0] = MakeAtom(drmmode_prop->name, strlen(drmmode_prop->name), TRUE);
-			range[0] = drmmode_prop->values[0];
-			range[1] = drmmode_prop->values[1];
-			err = RRConfigureOutputProperty(output->randr_output, p->atoms[0],
-							FALSE, TRUE,
-							drmmode_prop->flags & DRM_MODE_PROP_IMMUTABLE ? TRUE : FALSE,
-							2, range);
-			if (err != 0) {
-				xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
-					   "RRConfigureOutputProperty error, %d\n", err);
-			}
-			err = RRChangeOutputProperty(output->randr_output, p->atoms[0],
-						     XA_INTEGER, 32, PropModeReplace, 1,
-						     &value, FALSE, FALSE);
-			if (err != 0) {
-				xf86DrvMsg(output->scrn->scrnIndex, X_ERROR,
-					   "RRChangeOutputProperty error, %d\n", err);
-			}
+
+			nouveau_create_ranged_atom(output, &p->atoms[0],
+						  drmmode_prop->name,
+						  drmmode_prop->values[0],
+						  drmmode_prop->values[1],
+						  value,
+						  drmmode_prop->flags & DRM_MODE_PROP_IMMUTABLE ? TRUE : FALSE);
 		} else if (drmmode_prop->flags & DRM_MODE_PROP_ENUM) {
 			p->num_atoms = drmmode_prop->count_enums + 1;
 			p->atoms = calloc(p->num_atoms, sizeof(Atom));
-- 
1.8.2.1



More information about the Nouveau mailing list