Skip to contentSkip to conversation

ibm-acpi brightness fix

PATCH In review David Zeuthen 2 participants 2 messages Jan 29, 2006 – Jan 30, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ibm-acpi brightness fix

Hi,

The ibm-acpi driver allows user space to set the brightness of the display but the way it currently works is by fading from one of the eight levels to the other. While this effect is visually pleasing it's probably best taken care of by user space itself (and users of gnome-power-manager will notice that this is exactly what it does).

This patch removes the fading. Patch is against ibm-acpi 0.11 but it also applies to the drivers/acpi/ibm_acpi.c file in Linus' tree. I've tested this on a IBM Thinkpad T41. Please apply.

(Please keep me in the Cc - I'm not subscribed to the LKML)

David

ibm_acpi.c +6 -8
@@ -1351,7 +1351,7 @@ static int brightness_read(char *p)
 
 static int brightness_write(char *buf)
 {
-	int cmos_cmd, inc, i;
+	int cmos_cmd;
 	u8 level;
 	int new_level;
 	char *cmd;
@@ -1372,13 +1372,11 @@ static int brightness_write(char *buf)
 			return -EINVAL;
 
 		cmos_cmd = new_level > level ? BRIGHTNESS_UP : BRIGHTNESS_DOWN;
-		inc = new_level > level ? 1 : -1;
-		for (i = level; i != new_level; i += inc) {
-			if (!cmos_eval(cmos_cmd))
-				return -EIO;
-			if (!acpi_ec_write(brightness_offset, i + inc))
-				return -EIO;
-		}
+
+		if (!cmos_eval(cmos_cmd))
+			return -EIO;
+		if (!acpi_ec_write(brightness_offset, new_level))
+			return -EIO;
 	}
 
 	return 0;
#1 lore raw

Hi David,

Quoted 6 lines · David Zeuthen

The ibm-acpi driver allows user space to set the brightness of the display but the way it currently works is by fading from one of the eight levels to the other. While this effect is visually pleasing it's probably best taken care of by user space itself (and users of gnome-power-manager will notice that this is exactly what it does).

Thanks for the patch. Unfortunately, the fading is required on my X40 - setting a random brightness value just doesn't work without it. The EC probably expects it to happen that way since you can only go one step up or down with the hot keys.

Wishes,
Boris

Quoted 41 lines

This patch removes the fading. Patch is against ibm-acpi 0.11 but it also applies to the drivers/acpi/ibm_acpi.c file in Linus' tree. I've tested this on a IBM Thinkpad T41. Please apply.

(Please keep me in the Cc - I'm not subscribed to the LKML)

David

ibm_acpi.c +6 -8
@@ -1351,7 +1351,7 @@ static int brightness_read(char *p)
 
 static int brightness_write(char *buf)
 {
-	int cmos_cmd, inc, i;
+	int cmos_cmd;
 	u8 level;
 	int new_level;
 	char *cmd;
@@ -1372,13 +1372,11 @@ static int brightness_write(char *buf)
 			return -EINVAL;
 
 		cmos_cmd = new_level > level ? BRIGHTNESS_UP : BRIGHTNESS_DOWN;
-		inc = new_level > level ? 1 : -1;
-		for (i = level; i != new_level; i += inc) {
-			if (!cmos_eval(cmos_cmd))
-				return -EIO;
-			if (!acpi_ec_write(brightness_offset, i + inc))
-				return -EIO;
-		}
+
+		if (!cmos_eval(cmos_cmd))
+			return -EIO;
+		if (!acpi_ec_write(brightness_offset, new_level))
+			return -EIO;
 	}
 
 	return 0;