All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2.6.29] eeepc-laptop: report brightness control events via the input layer
@ 2009-04-03 17:57 Darren Salt
  2009-04-04  4:18 ` Matthew Garrett
  0 siblings, 1 reply; 23+ messages in thread
From: Darren Salt @ 2009-04-03 17:57 UTC (permalink / raw)
  To: linux-kernel, acpi4asus-user; +Cc: corentincj

This maps the brightness control events to one of two keys, either
KEY_BRIGHTNESSDOWN or KEY_BRIGHTNESSUP, as needed.

Some mapping has to be done due to the fact that the BIOS reports them as
<base value> + <current brightness index>; the selection is done according to
the sign of the change in brightness (if this is 0, no keypress is reported).

(Ref. http://lists.alioth.debian.org/pipermail/debian-eeepc-devel/2009-April/002001.html)

Signed-off-by: Darren Salt <linux@youmustbejoking.demon.co.uk>

diff -u a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
--- a/drivers/platform/x86/eeepc-laptop.c	2009-03-24 17:32:56.000000000 +0000
+++ b/drivers/platform/x86/eeepc-laptop.c	2009-04-03 13:24:59.000000000 +0100
@@ -166,6 +166,8 @@
 	{KE_KEY, 0x1b, KEY_ZOOM },
 	{KE_KEY, 0x1c, KEY_PROG2 },
 	{KE_KEY, 0x1d, KEY_PROG3 },
+	{KE_KEY, NOTIFY_BRN_MIN,     KEY_BRIGHTNESSDOWN },
+	{KE_KEY, NOTIFY_BRN_MIN + 2, KEY_BRIGHTNESSUP },
 	{KE_KEY, 0x30, KEY_SWITCHVIDEOMODE },
 	{KE_KEY, 0x31, KEY_SWITCHVIDEOMODE },
 	{KE_KEY, 0x32, KEY_SWITCHVIDEOMODE },
@@ -512,11 +514,17 @@
 	return 0;
 }
 
-static void notify_brn(void)
+static int notify_brn(void)
 {
+	/* returns the *previous* brightness, or -1 */
 	struct backlight_device *bd = eeepc_backlight_device;
 	if (bd)
+	{
+		int old = bd->props.brightness;
 		bd->props.brightness = read_brightness(bd);
+		return old;
+	}
+	return -1;
 }
 
 static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
@@ -558,17 +566,34 @@
 {
 	static struct key_entry *key;
 	u16 count;
+	int brn = -2;
 
 	if (!ehotk)
 		return;
 	if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
-		notify_brn();
+		brn = notify_brn();
 	count = ehotk->event_count[event % 128]++;
 	acpi_bus_generate_proc_event(ehotk->device, event, count);
 	acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class,
 					dev_name(&ehotk->device->dev), event,
 					count);
 	if (ehotk->inputdev) {
+		if (brn != -2)
+		{
+			/* brightness-change events need special
+			 * handling for conversion to key events
+			 */
+			if (brn == -1)
+				brn = event;
+			else
+				brn += NOTIFY_BRN_MIN;
+			if (event < brn)
+				event = NOTIFY_BRN_MIN; /* brightness down */
+			else if (event > brn)
+				event = NOTIFY_BRN_MIN + 2; /* ... up */
+			else
+				event = NOTIFY_BRN_MIN + 1; /* ... unchanged */
+		}
 		key = eepc_get_entry_by_scancode(event);
 		if (key) {
 			switch (key->type) {


-- 
| Darren Salt    | linux or ds at              | nr. Ashington, | Toon
| RISC OS, Linux | youmustbejoking,demon,co,uk | Northumberland | Army
| + Output *more* particulate pollutants.      BUFFER AGAINST GLOBAL WARMING.

I cut down trees, I eat my lunch, I go to the lavatory.

^ permalink raw reply	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2009-06-18 22:44 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-03 17:57 [PATCH 2.6.29] eeepc-laptop: report brightness control events via the input layer Darren Salt
2009-04-04  4:18 ` Matthew Garrett
2009-04-04  8:33   ` Corentin Chary
2009-04-04 12:20     ` Darren Salt
2009-04-04 12:35       ` Corentin Chary
2009-04-04 22:10         ` Darren Salt
2009-04-05  8:22           ` Corentin Chary
2009-06-08 15:24   ` Alan Jenkins
2009-06-13  8:55     ` Corentin Chary
2009-06-13  9:33       ` Alan Jenkins
2009-06-13 10:06         ` Corentin Chary
2009-06-13 12:55           ` Darren Salt
2009-06-13 17:51             ` Alan Jenkins
2009-06-14 19:26               ` Corentin Chary
2009-06-15  8:09                 ` Alan Jenkins
2009-06-15  8:12                   ` Alan Jenkins
2009-06-16  8:33                   ` [gpm] " Richard Hughes
2009-06-16  8:34                     ` Alan Jenkins
2009-06-16  8:47                       ` Richard Hughes
2009-06-16  9:44                         ` Corentin Chary
2009-06-16 10:04                           ` Richard Hughes
2009-06-18 13:33                             ` Alan Jenkins
2009-06-18 22:44                               ` Corentin Chary

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.