aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/video.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/video.c')
-rw-r--r--drivers/acpi/video.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index baa441929720..f261737636da 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>
@@ -481,6 +482,7 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
481 int status = AE_OK; 482 int status = AE_OK;
482 union acpi_object arg0 = { ACPI_TYPE_INTEGER }; 483 union acpi_object arg0 = { ACPI_TYPE_INTEGER };
483 struct acpi_object_list args = { 1, &arg0 }; 484 struct acpi_object_list args = { 1, &arg0 };
485 int state;
484 486
485 487
486 arg0.integer.value = level; 488 arg0.integer.value = level;
@@ -489,6 +491,10 @@ acpi_video_device_lcd_set_level(struct acpi_video_device *device, int level)
489 status = acpi_evaluate_object(device->dev->handle, "_BCM", 491 status = acpi_evaluate_object(device->dev->handle, "_BCM",
490 &args, NULL); 492 &args, NULL);
491 device->brightness->curr = level; 493 device->brightness->curr = level;
494 for (state = 2; state < device->brightness->count; state++)
495 if (level == device->brightness->levels[state])
496 device->backlight->props.brightness = state - 2;
497
492 return status; 498 return status;
493} 499}
494 500
@@ -626,6 +632,16 @@ acpi_video_bus_DOS(struct acpi_video_bus *video, int bios_flag, int lcd_flag)
626} 632}
627 633
628/* 634/*
635 * Simple comparison function used to sort backlight levels.
636 */
637
638static int
639acpi_video_cmp_level(const void *a, const void *b)
640{
641 return *(int *)a - *(int *)b;
642}
643
644/*
629 * Arg: 645 * Arg:
630 * device : video output device (LCD, CRT, ..) 646 * device : video output device (LCD, CRT, ..)
631 * 647 *
@@ -676,6 +692,10 @@ acpi_video_init_brightness(struct acpi_video_device *device)
676 count++; 692 count++;
677 } 693 }
678 694
695 /* don't sort the first two brightness levels */
696 sort(&br->levels[2], count - 2, sizeof(br->levels[2]),
697 acpi_video_cmp_level, NULL);
698
679 if (count < 2) 699 if (count < 2)
680 goto out_free_levels; 700 goto out_free_levels;
681 701