Commit 77675886 authored by Alexey Starikovskiy's avatar Alexey Starikovskiy Committed by Greg Kroah-Hartman

ACPI: VIDEO: Adjust current level to closest available one.

patch 63f0edfc in mainline.

ACPI: VIDEO: Adjust current level to closest available one.
Signed-off-by: default avatarAlexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
Cc: Tobias Powalowski <t.powa@gmx.de>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 2fcce6c9
...@@ -1633,9 +1633,20 @@ static int ...@@ -1633,9 +1633,20 @@ static int
acpi_video_get_next_level(struct acpi_video_device *device, acpi_video_get_next_level(struct acpi_video_device *device,
u32 level_current, u32 event) 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; max = max_below = 0;
min = min_above = 255; 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++) { for (i = 0; i < device->brightness->count; i++) {
l = device->brightness->levels[i]; l = device->brightness->levels[i];
if (l < min) if (l < min)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment