* [patch 08/19] Implementation of acpi_video_get_next_level()
@ 2006-12-19 20:56 akpm
2006-12-20 6:39 ` Len Brown
0 siblings, 1 reply; 2+ messages in thread
From: akpm @ 2006-12-19 20:56 UTC (permalink / raw)
To: lenb; +Cc: linux-acpi, akpm, linux-kernel, len.brown
From: Thomas Tuttle <linux-kernel@ttuttle.net>
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]
Cc: Len Brown <len.brown@intel.com>
Signed-off-by: Thomas Tuttle <linux-kernel@ttuttle.net>
Signed-off-by: Andrew Morton <akpm@osdl.org>
---
drivers/acpi/video.c | 41 ++++++++++++++++++++++++++++++++++-------
1 files changed, 34 insertions(+), 7 deletions(-)
diff -puN drivers/acpi/video.c~implementation-of-acpi_video_get_next_level drivers/acpi/video.c
--- a/drivers/acpi/video.c~implementation-of-acpi_video_get_next_level
+++ a/drivers/acpi/video.c
@@ -3,6 +3,7 @@
*
* Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
* Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
+ * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
*
* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
*
@@ -47,11 +48,11 @@
#define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
#define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
-#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82
-#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83
-#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84
-#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85
-#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86
+#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85
+#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
+#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
+#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88
+#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89
#define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
#define ACPI_VIDEO_HEAD_END (~0u)
@@ -1502,8 +1503,34 @@ static int
acpi_video_get_next_level(struct acpi_video_device *device,
u32 level_current, u32 event)
{
- /*Fix me */
- return level_current;
+ int min, max, min_above, max_below, i, l;
+ max = max_below = 0;
+ min = min_above = 255;
+ for (i = 0; i < device->brightness->count; i++) {
+ l = device->brightness->levels[i];
+ if (l < min)
+ min = l;
+ if (l > max)
+ max = l;
+ if (l < min_above && l > level_current)
+ min_above = l;
+ if (l > max_below && l < level_current)
+ max_below = l;
+ }
+
+ switch (event) {
+ case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:
+ return (level_current < max) ? min_above : min;
+ case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:
+ return (level_current < max) ? min_above : max;
+ case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS:
+ return (level_current > min) ? max_below : min;
+ case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:
+ case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:
+ return 0;
+ default:
+ return level_current;
+ }
}
static void
_
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [patch 08/19] Implementation of acpi_video_get_next_level()
2006-12-19 20:56 [patch 08/19] Implementation of acpi_video_get_next_level() akpm
@ 2006-12-20 6:39 ` Len Brown
0 siblings, 0 replies; 2+ messages in thread
From: Len Brown @ 2006-12-20 6:39 UTC (permalink / raw)
To: akpm; +Cc: linux-acpi, linux-kernel, len.brown
Applied.
thanks,
-Len
On Tuesday 19 December 2006 15:56, akpm@osdl.org wrote:
> From: Thomas Tuttle <linux-kernel@ttuttle.net>
>
> 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]
> Cc: Len Brown <len.brown@intel.com>
> Signed-off-by: Thomas Tuttle <linux-kernel@ttuttle.net>
> Signed-off-by: Andrew Morton <akpm@osdl.org>
> ---
>
> drivers/acpi/video.c | 41 ++++++++++++++++++++++++++++++++++-------
> 1 files changed, 34 insertions(+), 7 deletions(-)
>
> diff -puN drivers/acpi/video.c~implementation-of-acpi_video_get_next_level drivers/acpi/video.c
> --- a/drivers/acpi/video.c~implementation-of-acpi_video_get_next_level
> +++ a/drivers/acpi/video.c
> @@ -3,6 +3,7 @@
> *
> * Copyright (C) 2004 Luming Yu <luming.yu@intel.com>
> * Copyright (C) 2004 Bruno Ducrot <ducrot@poupinou.org>
> + * Copyright (C) 2006 Thomas Tuttle <linux-kernel@ttuttle.net>
> *
> * ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> *
> @@ -47,11 +48,11 @@
> #define ACPI_VIDEO_NOTIFY_NEXT_OUTPUT 0x83
> #define ACPI_VIDEO_NOTIFY_PREV_OUTPUT 0x84
>
> -#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x82
> -#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x83
> -#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x84
> -#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x85
> -#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x86
> +#define ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS 0x85
> +#define ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS 0x86
> +#define ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS 0x87
> +#define ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS 0x88
> +#define ACPI_VIDEO_NOTIFY_DISPLAY_OFF 0x89
>
> #define ACPI_VIDEO_HEAD_INVALID (~0u - 1)
> #define ACPI_VIDEO_HEAD_END (~0u)
> @@ -1502,8 +1503,34 @@ static int
> acpi_video_get_next_level(struct acpi_video_device *device,
> u32 level_current, u32 event)
> {
> - /*Fix me */
> - return level_current;
> + int min, max, min_above, max_below, i, l;
> + max = max_below = 0;
> + min = min_above = 255;
> + for (i = 0; i < device->brightness->count; i++) {
> + l = device->brightness->levels[i];
> + if (l < min)
> + min = l;
> + if (l > max)
> + max = l;
> + if (l < min_above && l > level_current)
> + min_above = l;
> + if (l > max_below && l < level_current)
> + max_below = l;
> + }
> +
> + switch (event) {
> + case ACPI_VIDEO_NOTIFY_CYCLE_BRIGHTNESS:
> + return (level_current < max) ? min_above : min;
> + case ACPI_VIDEO_NOTIFY_INC_BRIGHTNESS:
> + return (level_current < max) ? min_above : max;
> + case ACPI_VIDEO_NOTIFY_DEC_BRIGHTNESS:
> + return (level_current > min) ? max_below : min;
> + case ACPI_VIDEO_NOTIFY_ZERO_BRIGHTNESS:
> + case ACPI_VIDEO_NOTIFY_DISPLAY_OFF:
> + return 0;
> + default:
> + return level_current;
> + }
> }
>
> static void
> _
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2006-12-20 6:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-12-19 20:56 [patch 08/19] Implementation of acpi_video_get_next_level() akpm
2006-12-20 6:39 ` Len Brown
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.