Skip to content

Commit

Permalink
ACPI: VIDEO: Adjust current level to closest available one.
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Alexey Starikovskiy authored and Len Brown committed Sep 5, 2007
1 parent 4500ca8 commit 63f0edf
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion drivers/acpi/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -1636,9 +1636,20 @@ static int
acpi_video_get_next_level(struct acpi_video_device *device,
u32 level_current, u32 event)
{
int min, max, min_above, max_below, i, l;
int min, max, min_above, max_below, i, l, delta = 255;
max = max_below = 0;
min = min_above = 255;
/* Find closest level to level_current */
for (i = 0; i < device->brightness->count; i++) {
l = device->brightness->levels[i];
if (abs(l - level_current) < abs(delta)) {
delta = l - level_current;
if (!delta)
break;
}
}
/* Ajust level_current to closest available level */
level_current += delta;
for (i = 0; i < device->brightness->count; i++) {
l = device->brightness->levels[i];
if (l < min)
Expand Down

0 comments on commit 63f0edf

Please sign in to comment.