xf86-video-intel: src/intel_display.c

Chris Wilson ickle at kemper.freedesktop.org
Wed Aug 25 17:00:31 PDT 2010


 src/intel_display.c |   55 ++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 45 insertions(+), 10 deletions(-)

New commits:
commit b7a8087fbc5cbd944f8345b8a098270c1f63ebab
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Aug 25 15:44:20 2010 +0100

    Revert "Leave adjustment of backlight to the driver."
    
    This reverts commit 9c3e34703dcdc2155faeb2c1886930def19d9989.
    
    This commit is not ready, as first the driver needs to handle all
    controllers, especially those that ignore the BLC and require their own
    interface.  Fortunately, by moving that discovery into the kernel - where
    it just means finding which ACPI device is attached to the video and has a
    backlight interface - the userspace code should become much more sane,
    and work even with multi-gpu, multi-lid systems.
    
    But that is for tomorrow.

diff --git a/src/intel_display.c b/src/intel_display.c
index c945104..4da2790 100644
--- a/src/intel_display.c
+++ b/src/intel_display.c
@@ -80,7 +80,6 @@ struct intel_property {
 struct intel_output {
 	struct intel_mode *mode;
 	int output_id;
-	int dpms_id;
 	drmModeConnectorPtr mode_output;
 	drmModeEncoderPtr mode_encoder;
 	int num_props;
@@ -862,16 +861,56 @@ intel_output_destroy(xf86OutputPtr output)
 }
 
 static void
+intel_output_dpms_backlight(xf86OutputPtr output, int oldmode, int mode)
+{
+	struct intel_output *intel_output = output->driver_private;
+
+	if (!intel_output->backlight_iface)
+		return;
+
+	if (mode == DPMSModeOn) {
+		/* If we're going from off->on we may need to turn on the backlight. */
+		if (oldmode != DPMSModeOn)
+			intel_output_backlight_set(output,
+						   intel_output->backlight_active_level);
+	} else {
+		/* Only save the current backlight value if we're going from on to off. */
+		if (oldmode == DPMSModeOn)
+			intel_output->backlight_active_level = intel_output_backlight_get(output);
+		intel_output_backlight_set(output, 0);
+	}
+}
+
+static void
 intel_output_dpms(xf86OutputPtr output, int dpms)
 {
 	struct intel_output *intel_output = output->driver_private;
+	drmModeConnectorPtr koutput = intel_output->mode_output;
 	struct intel_mode *mode = intel_output->mode;
+	int i;
 
-	drmModeConnectorSetProperty(mode->fd,
-				    intel_output->output_id,
-				    intel_output->dpms_id,
-				    dpms);
-	intel_output->dpms_mode = dpms;
+	for (i = 0; i < koutput->count_props; i++) {
+		drmModePropertyPtr props;
+
+		props = drmModeGetProperty(mode->fd, koutput->props[i]);
+		if (!props)
+			continue;
+
+		if (!strcmp(props->name, "DPMS")) {
+			drmModeConnectorSetProperty(mode->fd,
+						    intel_output->output_id,
+						    props->prop_id,
+						    dpms);
+			intel_output_dpms_backlight(output,
+						      intel_output->dpms_mode,
+						      dpms);
+			intel_output->dpms_mode = dpms;
+			drmModeFreeProperty(props);
+			return;
+		}
+
+		drmModeFreeProperty(props);
+	}
 }
 
 int
@@ -922,10 +961,6 @@ intel_output_create_resources(xf86OutputPtr output)
 
 		drmmode_prop = drmModeGetProperty(mode->fd,
 						  mode_output->props[i]);
-
-		if (!strcmp(drmmode_prop->name, "DPMS"))
-			intel_output->dpms_id = drmmode_prop->prop_id;
-
 		if (intel_property_ignore(drmmode_prop)) {
 			drmModeFreeProperty(drmmode_prop);
 			continue;


More information about the xorg-commit mailing list