aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/video.c
diff options
context:
space:
mode:
authorThomas Tuttle <linux-kernel@ttuttle.net>2006-12-19 15:56:14 -0500
committerLen Brown <len.brown@intel.com>2006-12-20 01:38:38 -0500
commitf4715189dfb1c381ad36b7e02e3716fb7a7f84db (patch)
treecaa02518b93f2d6d5a26138a23fbee82e8fd497c /drivers/acpi/video.c
parent4afaf54b3b97fa8cf2d1d9bcd7612b195acb53ae (diff)
ACPI: Implement acpi_video_get_next_level()
acpi_video_get_next_level was supposed to implement an algorithm to select a new brightness level based on the old brightness level of an ACPI video device, but it simply says "/* Fix me */" and returns the current brightness. This patch implements acpi_video_get_next_level properly. It had to change a few constants at the top of the file because they were (apparently) wrong, but it appears to work on my Dell Inspiron e1405 (with BIOS A05 only--BIOS A04 doesn't seem to send ACPI video hotkey events). [akpm@osdl.org: cleanups] Signed-off-by: Thomas Tuttle <linux-kernel@ttuttle.net> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/video.c')
-rw-r--r--drivers/acpi/video.c41
1 files changed, 34 insertions, 7 deletions
diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 56666a982476..9200a46c38bd 100644
--- a/drivers/acpi/video.c
+++ b/drivers/acpi/video.c
@@ -3,6 +3,7 @@
3 * 3 *
4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com> 4 * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
5 * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org> 5 * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
6 * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
6 * 7 *
7 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 8 * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 * 9 *
@@ -47,11 +48,11 @@
47#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83 48#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
48#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84 49#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
49 50
50#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82 51#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85
51#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83 52#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
52#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84 53#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
53#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85 54#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88
54#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86 55#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89
55 56
56#define ACPI_VIDEO_HEAD_INVALID (~0u - 1) 57#define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
57#define ACPI_VIDEO_HEAD_END (~0u) 58#define ACPI_VIDEO_HEAD_END (~0u)
@@ -1509,8 +1510,34 @@ static int
1509acpi_video_get_next_level(struct acpi_video_device *device, 1510acpi_video_get_next_level(struct acpi_video_device *device,
1510 u32 level_current, u32 event) 1511 u32 level_current, u32 event)
1511{ 1512{
1512 /*Fix me */ 1513 int min, max, min_above, max_below, i, l;
1513 return level_current; 1514 max = max_below = 0;
1515 min = min_above = 255;
1516 for (i = 0; i < device->brightness->count; i++) {
1517 l = device->brightness->levels[i];
1518 if (l < min)
1519 min = l;
1520 if (l > max)
1521 max = l;
1522 if (l < min_above && l > level_current)
1523 min_above = l;
1524 if (l > max_below && l < level_current)
1525 max_below = l;
1526 }
1527
1528 switch (event) {
1529 case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:
1530 return (level_current < max) ? min_above : min;
1531 case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:
1532 return (level_current < max) ? min_above : max;
1533 case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS:
1534 return (level_current > min) ? max_below : min;
1535 case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:
1536 case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:
1537 return 0;
1538 default:
1539 return level_current;
1540 }
1514} 1541}
1515 1542
1516static void 1543static void