diff options
author | Darren Salt <linux@youmustbejoking.demon.co.uk> | 2009-04-27 03:23:38 -0400 |
---|---|---|
committer | Len Brown <len.brown@intel.com> | 2009-05-14 11:19:32 -0400 |
commit | 64b86b6583db832b28bb54575e32b9e2a1a7d84f (patch) | |
tree | 161e97f7d1cd6602cf6282d3f3960dd3f7505589 /drivers/platform | |
parent | fbc97e4c5c31ea198f912196b1379d7493362800 (diff) |
eeepc-laptop: report brightness control events via the input layer
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>
Signed-off-by: Corentin Chary <corentincj@iksaif.net>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/platform')
-rw-r--r-- | drivers/platform/x86/eeepc-laptop.c | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c index e21f7cd72e4e..f54cfeac5221 100644 --- a/drivers/platform/x86/eeepc-laptop.c +++ b/drivers/platform/x86/eeepc-laptop.c | |||
@@ -166,6 +166,8 @@ static struct key_entry eeepc_keymap[] = { | |||
166 | {KE_KEY, 0x1b, KEY_ZOOM }, | 166 | {KE_KEY, 0x1b, KEY_ZOOM }, |
167 | {KE_KEY, 0x1c, KEY_PROG2 }, | 167 | {KE_KEY, 0x1c, KEY_PROG2 }, |
168 | {KE_KEY, 0x1d, KEY_PROG3 }, | 168 | {KE_KEY, 0x1d, KEY_PROG3 }, |
169 | {KE_KEY, NOTIFY_BRN_MIN, KEY_BRIGHTNESSDOWN }, | ||
170 | {KE_KEY, NOTIFY_BRN_MIN + 2, KEY_BRIGHTNESSUP }, | ||
169 | {KE_KEY, 0x30, KEY_SWITCHVIDEOMODE }, | 171 | {KE_KEY, 0x30, KEY_SWITCHVIDEOMODE }, |
170 | {KE_KEY, 0x31, KEY_SWITCHVIDEOMODE }, | 172 | {KE_KEY, 0x31, KEY_SWITCHVIDEOMODE }, |
171 | {KE_KEY, 0x32, KEY_SWITCHVIDEOMODE }, | 173 | {KE_KEY, 0x32, KEY_SWITCHVIDEOMODE }, |
@@ -512,11 +514,16 @@ static int eeepc_hotk_check(void) | |||
512 | return 0; | 514 | return 0; |
513 | } | 515 | } |
514 | 516 | ||
515 | static void notify_brn(void) | 517 | static int notify_brn(void) |
516 | { | 518 | { |
519 | /* returns the *previous* brightness, or -1 */ | ||
517 | struct backlight_device *bd = eeepc_backlight_device; | 520 | struct backlight_device *bd = eeepc_backlight_device; |
518 | if (bd) | 521 | if (bd) { |
522 | int old = bd->props.brightness; | ||
519 | bd->props.brightness = read_brightness(bd); | 523 | bd->props.brightness = read_brightness(bd); |
524 | return old; | ||
525 | } | ||
526 | return -1; | ||
520 | } | 527 | } |
521 | 528 | ||
522 | static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) | 529 | static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) |
@@ -558,17 +565,33 @@ static void eeepc_hotk_notify(acpi_handle handle, u32 event, void *data) | |||
558 | { | 565 | { |
559 | static struct key_entry *key; | 566 | static struct key_entry *key; |
560 | u16 count; | 567 | u16 count; |
568 | int brn = -ENODEV; | ||
561 | 569 | ||
562 | if (!ehotk) | 570 | if (!ehotk) |
563 | return; | 571 | return; |
564 | if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) | 572 | if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) |
565 | notify_brn(); | 573 | brn = notify_brn(); |
566 | count = ehotk->event_count[event % 128]++; | 574 | count = ehotk->event_count[event % 128]++; |
567 | acpi_bus_generate_proc_event(ehotk->device, event, count); | 575 | acpi_bus_generate_proc_event(ehotk->device, event, count); |
568 | acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class, | 576 | acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class, |
569 | dev_name(&ehotk->device->dev), event, | 577 | dev_name(&ehotk->device->dev), event, |
570 | count); | 578 | count); |
571 | if (ehotk->inputdev) { | 579 | if (ehotk->inputdev) { |
580 | if (brn != -ENODEV) { | ||
581 | /* brightness-change events need special | ||
582 | * handling for conversion to key events | ||
583 | */ | ||
584 | if (brn < 0) | ||
585 | brn = event; | ||
586 | else | ||
587 | brn += NOTIFY_BRN_MIN; | ||
588 | if (event < brn) | ||
589 | event = NOTIFY_BRN_MIN; /* brightness down */ | ||
590 | else if (event > brn) | ||
591 | event = NOTIFY_BRN_MIN + 2; /* ... up */ | ||
592 | else | ||
593 | event = NOTIFY_BRN_MIN + 1; /* ... unchanged */ | ||
594 | } | ||
572 | key = eepc_get_entry_by_scancode(event); | 595 | key = eepc_get_entry_by_scancode(event); |
573 | if (key) { | 596 | if (key) { |
574 | switch (key->type) { | 597 | switch (key->type) { |