All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Tuttle <linux-kernel@ttuttle.net>
To: len.brown@intel.com
Cc: linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org,
	acpi-devel@lists.sourceforge.net, linux-acpi@intel.com
Subject: [PATCH] Implementation of acpi_video_get_next_level
Date: Fri, 24 Nov 2006 14:33:47 -0500	[thread overview]
Message-ID: <20061124193347.GA22622@lion> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 931 bytes --]

PATCH: Implementation of acpi_video_get_level

(patch file attached)

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).

I'm sending this to Len Brown, the linux-kernel and linux-acpi lists at
kernel.org, the acpi-devel list at Sourceforge, and the linux-acpi alias
at Intel.  I'm not sure who should be the one to apply it, but it's a
small and simple enough patch that it shouldn't require a complicated
review.

Thanks for your time, and hope this helps,

Thomas Tuttle

[-- Attachment #1.2: acpi_video_get_next_level.patch --]
[-- Type: text/plain, Size: 2166 bytes --]

diff --git a/drivers/acpi/video.c b/drivers/acpi/video.c
index 56666a9..2fc78ca 100644
--- a/drivers/acpi/video.c
+++ b/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_CYCLE		0x82
 #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)
@@ -1509,8 +1510,30 @@ 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

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

             reply	other threads:[~2006-11-24 19:35 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-11-24 19:33 Thomas Tuttle [this message]
2006-11-24 19:36 ` [PATCH] Implementation of acpi_video_get_next_level Thomas Tuttle
2006-11-27  0:18   ` ACPI patch submission (was: [PATCH] Implementation of acpi_video_get_next_level) Thomas Tuttle

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20061124193347.GA22622@lion \
    --to=linux-kernel@ttuttle.net \
    --cc=acpi-devel@lists.sourceforge.net \
    --cc=len.brown@intel.com \
    --cc=linux-acpi@intel.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.