Re: [PATCH] ACPI / Video: Fix initial brightness problem on Acer Ferrari One

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

 



On Thursday 01 April 2010, Rafael J. Wysocki wrote:
> On Thursday 01 April 2010, Zhang Rui wrote:
> > On Thu, 2010-04-01 at 09:34 +0800, Zhang Rui wrote:
> > > On Thu, 2010-04-01 at 09:19 +0800, Rafael J. Wysocki wrote:
> > > > From: Rafael J. Wysocki <rjw@xxxxxxx>
...
> > > > +		if (!br->flags._BCL_no_ac_battery_levels)
> > > > +			level = power_supply_is_system_supplied() ?
> > > > +
> > > > 						br->levels[0] : br->levels[1];
> > > 
> > > this doesn't work currently.
> > > br->levels[0] and br->levels[1] doesn't equal the "AC power" value and
> > > "Battery" value, because the "AC power" and "Battery" value is not
> > > exported by many BIOS at all.
> 
> But if the BIOS doesn't export these values,
> br->flags._BCL_no_ac_battery_levels will be true, won't it?
> 
> > I mean, for these laptops, br->levels[0] and br->levels[1] equals the
> > first and second elements in _BCL package.
> > But we can not use them as the "AC power" and "Battery" value.
> 
> In that cases the if (!br->flags._BCL_no_ac_battery_levels) condition won't
> be satisfied.
> 
> On a second thought, though, something like this also works and is simpler.

OK, Matthew wanted me to make the second expression using the ternary operator
more readable.

Rafael

---
From: Rafael J. Wysocki <rjw@xxxxxxx>
Subject: ACPI / Video: Fix initial brightness problem on Acer Ferrari One (v. 2)

On Acer Ferrari One, when _BQC is invoked for the first time, the
minimum brightness is returned, so the ACPI video drivers sets the
minimum brightness on boot.  This is not desirable, so use the
following rule:
	Set brightness to either the level supposed to be used on
	AC power, or the brightness level supposed to be used on
	battery, depending on whether or not the system is on AC
	power.  If these values are not exported by the BIOS, use the
	brightness level initially returned by _BQC.  If that value
	is invalid, use the maximum brightness level.

Signed-off-by: Rafael J. Wysocki <rjw@xxxxxxx>
---
 drivers/acpi/video.c |   16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

Index: linux-2.6/drivers/acpi/video.c
===================================================================
--- linux-2.6.orig/drivers/acpi/video.c
+++ linux-2.6/drivers/acpi/video.c
@@ -44,6 +44,7 @@
 #include <acpi/acpi_bus.h>
 #include <acpi/acpi_drivers.h>
 #include <linux/suspend.h>
+#include <linux/power_supply.h>
 
 #define PREFIX "ACPI: "
 
@@ -915,6 +916,18 @@ acpi_video_init_brightness(struct acpi_v
 
 	br->flags._BQC_use_index = (level == max_level ? 0 : 1);
 
+	/*
+	 * Set brightness to the "AC power" value if on AC power or to the
+	 * "battery" value otherwise.  If these vaules are not exported, try
+	 * to use the value returned by the initial _BQC and fall back to
+	 * max_level.
+	 */
+	if (!br->flags._BCL_no_ac_battery_levels) {
+		level = power_supply_is_system_supplied() ?
+					br->levels[0] : br->levels[1];
+		goto set_level;
+	}
+
 	if (!br->flags._BQC_use_index) {
 		/*
 		 * Set the backlight to the initial state.
@@ -930,7 +943,8 @@ acpi_video_init_brightness(struct acpi_v
 
 	if (br->flags._BCL_reversed)
 		level_old = (br->count - 1) - level_old;
-	level = br->levels[level_old];
+	level = (level_old >= 0 && level_old < br->count) ?
+				br->levels[level_old] : max_level;
 
 set_level:
 	result = acpi_video_device_lcd_set_level(device, level);
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux