]> err.no Git - linux-2.6/commitdiff
ACPI: VIDEO: Adjust current level to closest available one.
authorAlexey Starikovskiy <astarikovskiy@suse.de>
Mon, 3 Sep 2007 12:30:08 +0000 (16:30 +0400)
committerLen Brown <len.brown@intel.com>
Wed, 5 Sep 2007 18:24:35 +0000 (14:24 -0400)
Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/video.c

index 83aa41c5c59f6251ae0a3077aac42cd8c02c57fe..8a60a3d7001cdbb02c332911ee23326e583197be 100644 (file)
@@ -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)