diff options
author | Alexey Starikovskiy <astarikovskiy@suse.de> | 2007-09-03 08:30:08 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2007-09-05 14:24:35 -0400 |
commit | 63f0edfc0b7f8058f9d3f9b572615ec97ae011ba (patch) | |
tree | f5bb35a540e9550649bb8633576acf242b1fa866 /drivers | |
parent | 4500ca8e221e72cc38e7c239b9b1a041031ee450 (diff) |
ACPI: VIDEO: Adjust current level to closest available one.
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/acpi/video.c | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c index 83aa41c5c59f..8a60a3d7001c 100644 --- a/drivers/acpi/video.c +++ b/drivers/acpi/video.c | |||
@@ -1636,9 +1636,20 @@ static int | |||
1636 | acpi_video_get_next_level(struct acpi_video_device *device, | 1636 | acpi_video_get_next_level(struct acpi_video_device *device, |
1637 | u32 level_current, u32 event) | 1637 | u32 level_current, u32 event) |
1638 | { | 1638 | { |
1639 | int min, max, min_above, max_below, i, l; | 1639 | int min, max, min_above, max_below, i, l, delta = 255; |
1640 | max = max_below = 0; | 1640 | max = max_below = 0; |
1641 | min = min_above = 255; | 1641 | min = min_above = 255; |
1642 | /* Find closest level to level_current */ | ||
1643 | for (i = 0; i < device->brightness->count; i++) { | ||
1644 | l = device->brightness->levels[i]; | ||
1645 | if (abs(l - level_current) < abs(delta)) { | ||
1646 | delta = l - level_current; | ||
1647 | if (!delta) | ||
1648 | break; | ||
1649 | } | ||
1650 | } | ||
1651 | /* Ajust level_current to closest available level */ | ||
1652 | level_current += delta; | ||
1642 | for (i = 0; i < device->brightness->count; i++) { | 1653 | for (i = 0; i < device->brightness->count; i++) { |
1643 | l = device->brightness->levels[i]; | 1654 | l = device->brightness->levels[i]; |
1644 | if (l < min) | 1655 | if (l < min) |