aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZhang Rui <rui.zhang@intel.com>2008-12-11 16:24:52 -0500
committerLen Brown <len.brown@intel.com>2008-12-11 16:24:52 -0500
commit935e5f290ec1eb0f1c15004421f5fd3154380fd5 (patch)
tree2f116b2de376df6621ab700246a96e25a1183b84
parent6c34bc2976b30dc8b56392c020e25bae1f363cab (diff)
ACPI: video: Fix reversed brightness behavior on ThinkPad SL series
Section B.6.2 of ACPI 3.0b specification that defines _BCL method doesn't require the brightness levels returned to be sorted. At least ThinkPad SL300 (and probably all IdeaPads) returns the array reversed (i.e. bightest levels have lowest indexes), which causes the brightness management behave in completely reversed manner on these machines (brightness increases when the laptop is idle, while the display dims when used). Sorting the array by brightness level values after reading the list fixes the issue. http://bugzilla.kernel.org/show_bug.cgi?id=12037 Signed-off-by: Zhang Rui <rui.zhang@intel.com> Tested-by: Lubomir Rintel <lkundrak@v3.sk> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/video.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index baa441929720..38bf8b43fd19 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -36,6 +36,7 @@
36#include <linux/backlight.h> 36#include <linux/backlight.h>
37#include <linux/thermal.h> 37#include <linux/thermal.h>
38#include <linux/video_output.h> 38#include <linux/video_output.h>
39#include <linux/sort.h>
39#include <asm/uaccess.h> 40#include <asm/uaccess.h>
40 41
41#include <acpi/acpi_bus.h> 42#include <acpi/acpi_bus.h>
@@ -626,6 +627,16 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
626} 627}
627 628
628/* 629/*
630 * Simple comparison function used to sort backlight levels.
631 */
632
633static int
634acpi_video_cmp_level(const void *a, const void *b)
635{
636 return *(int *)a - *(int *)b;
637}
638
639/*
629 * Arg: 640 * Arg:
630 * device : video output device (LCD, CRT, ..) 641 * device : video output device (LCD, CRT, ..)
631 * 642 *
@@ -676,6 +687,10 @@ acpi_video_init_brightness(struct acpi_video_device *device)
676 count++; 687 count++;
677 } 688 }
678 689
690 /* don't sort the first two brightness levels */
691 sort(&br->levels[2], count - 2, sizeof(br->levels[2]),
692 acpi_video_cmp_level, NULL);
693
679 if (count < 2) 694 if (count < 2)
680 goto out_free_levels; 695 goto out_free_levels;
681 696