aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Jenkins <alan-jenkins@tuffmail.co.uk>2009-12-03 02:45:04 -0500
committerLen Brown <len.brown@intel.com>2009-12-09 15:54:32 -0500
commitbf9598bcd5a73385ced7880ea09998a545e03dd8 (patch)
treed95811ba105cd2bf4fea7a2b93df4bc71ea77b92
parent463b4e474ed0905ffc27ee347648739dbfb03acc (diff)
eeepc-laptop: refactor notifications
Separate out input_notify(), in a similar way to how notify_brn() is already separated. This will allow all the functions which refer to the input device to be grouped together. This includes a small behaviour change - we now synthesize brightness up/down key events even if the brightness is already at the maximum/minimum value. This is consistent with the new uevent interface. Signed-off-by: Alan Jenkins <alan-jenkins@tuffmail.co.uk> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/platform/x86/eeepc-laptop.c71
1 files changed, 39 insertions, 32 deletions
diff --git a/drivers/platform/x86/eeepc-laptop.c b/drivers/platform/x86/eeepc-laptop.c
index 04a59d3bcad2..b4eacb68a19d 100644
--- a/drivers/platform/x86/eeepc-laptop.c
+++ b/drivers/platform/x86/eeepc-laptop.c
@@ -655,9 +655,8 @@ static int eeepc_hotk_init(void)
655 return 0; 655 return 0;
656} 656}
657 657
658static int notify_brn(void) 658static int eeepc_backlight_notify(void)
659{ 659{
660 /* returns the *previous* brightness, or -1 */
661 struct backlight_device *bd = eeepc_backlight_device; 660 struct backlight_device *bd = eeepc_backlight_device;
662 int old = bd->props.brightness; 661 int old = bd->props.brightness;
663 662
@@ -731,50 +730,58 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
731 eeepc_rfkill_hotplug(); 730 eeepc_rfkill_hotplug();
732} 731}
733 732
734static void eeepc_hotk_notify(struct acpi_device *device, u32 event) 733static void eeepc_input_notify(int event)
735{ 734{
736 static struct key_entry *key; 735 static struct key_entry *key;
736
737 key = eepc_get_entry_by_scancode(event);
738 if (key) {
739 switch (key->type) {
740 case KE_KEY:
741 input_report_key(ehotk->inputdev, key->keycode,
742 1);
743 input_sync(ehotk->inputdev);
744 input_report_key(ehotk->inputdev, key->keycode,
745 0);
746 input_sync(ehotk->inputdev);
747 break;
748 }
749 }
750}
751
752static void eeepc_hotk_notify(struct acpi_device *device, u32 event)
753{
737 u16 count; 754 u16 count;
738 int brn = -ENODEV;
739 755
740 if (event > ACPI_MAX_SYS_NOTIFY) 756 if (event > ACPI_MAX_SYS_NOTIFY)
741 return; 757 return;
742 if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
743 brn = notify_brn();
744 count = ehotk->event_count[event % 128]++; 758 count = ehotk->event_count[event % 128]++;
745 acpi_bus_generate_proc_event(ehotk->device, event, count); 759 acpi_bus_generate_proc_event(ehotk->device, event, count);
746 acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class, 760 acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class,
747 dev_name(&ehotk->device->dev), event, 761 dev_name(&ehotk->device->dev), event,
748 count); 762 count);
749 if (ehotk->inputdev) { 763
750 /* brightness-change events need special 764 if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) {
751 * handling for conversion to key events 765 int old_brightness, new_brightness;
752 */ 766
753 if (brn < 0) 767 /* Update backlight device. */
754 brn = event; 768 old_brightness = eeepc_backlight_notify();
755 else 769
756 brn += NOTIFY_BRN_MIN; 770 /* Convert brightness event to keypress (obsolescent hack). */
757 if (event < brn) 771 new_brightness = event - NOTIFY_BRN_MIN;
772
773 if (new_brightness < old_brightness) {
758 event = NOTIFY_BRN_MIN; /* brightness down */ 774 event = NOTIFY_BRN_MIN; /* brightness down */
759 else if (event > brn) 775 } else if (new_brightness > old_brightness) {
760 event = NOTIFY_BRN_MIN + 2; /* ... up */ 776 event = NOTIFY_BRN_MAX; /* brightness up */
761 else 777 } else {
762 event = NOTIFY_BRN_MIN + 1; /* ... unchanged */ 778 /*
763 779 * no change in brightness - already at min/max,
764 key = eepc_get_entry_by_scancode(event); 780 * event will be desired value (or else ignored).
765 if (key) { 781 */
766 switch (key->type) {
767 case KE_KEY:
768 input_report_key(ehotk->inputdev, key->keycode,
769 1);
770 input_sync(ehotk->inputdev);
771 input_report_key(ehotk->inputdev, key->keycode,
772 0);
773 input_sync(ehotk->inputdev);
774 break;
775 }
776 } 782 }
777 } 783 }
784 eeepc_input_notify(event);
778} 785}
779 786
780static int eeepc_register_rfkill_notifier(char *node) 787static int eeepc_register_rfkill_notifier(char *node)