Commit bf9598bc authored by Alan Jenkins's avatar Alan Jenkins Committed by Len Brown

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: default avatarAlan Jenkins <alan-jenkins@tuffmail.co.uk>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 463b4e47
...@@ -655,9 +655,8 @@ static int eeepc_hotk_init(void) ...@@ -655,9 +655,8 @@ static int eeepc_hotk_init(void)
return 0; return 0;
} }
static int notify_brn(void) static int eeepc_backlight_notify(void)
{ {
/* returns the *previous* brightness, or -1 */
struct backlight_device *bd = eeepc_backlight_device; struct backlight_device *bd = eeepc_backlight_device;
int old = bd->props.brightness; int old = bd->props.brightness;
...@@ -731,50 +730,58 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data) ...@@ -731,50 +730,58 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
eeepc_rfkill_hotplug(); eeepc_rfkill_hotplug();
} }
static void eeepc_hotk_notify(struct acpi_device *device, u32 event) static void eeepc_input_notify(int event)
{ {
static struct key_entry *key; static struct key_entry *key;
key = eepc_get_entry_by_scancode(event);
if (key) {
switch (key->type) {
case KE_KEY:
input_report_key(ehotk->inputdev, key->keycode,
1);
input_sync(ehotk->inputdev);
input_report_key(ehotk->inputdev, key->keycode,
0);
input_sync(ehotk->inputdev);
break;
}
}
}
static void eeepc_hotk_notify(struct acpi_device *device, u32 event)
{
u16 count; u16 count;
int brn = -ENODEV;
if (event > ACPI_MAX_SYS_NOTIFY) if (event > ACPI_MAX_SYS_NOTIFY)
return; return;
if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
brn = notify_brn();
count = ehotk->event_count[event % 128]++; count = ehotk->event_count[event % 128]++;
acpi_bus_generate_proc_event(ehotk->device, event, count); acpi_bus_generate_proc_event(ehotk->device, event, count);
acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class, acpi_bus_generate_netlink_event(ehotk->device->pnp.device_class,
dev_name(&ehotk->device->dev), event, dev_name(&ehotk->device->dev), event,
count); count);
if (ehotk->inputdev) {
/* brightness-change events need special if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) {
* handling for conversion to key events int old_brightness, new_brightness;
*/
if (brn < 0) /* Update backlight device. */
brn = event; old_brightness = eeepc_backlight_notify();
else
brn += NOTIFY_BRN_MIN; /* Convert brightness event to keypress (obsolescent hack). */
if (event < brn) new_brightness = event - NOTIFY_BRN_MIN;
if (new_brightness < old_brightness) {
event = NOTIFY_BRN_MIN; /* brightness down */ event = NOTIFY_BRN_MIN; /* brightness down */
else if (event > brn) } else if (new_brightness > old_brightness) {
event = NOTIFY_BRN_MIN + 2; /* ... up */ event = NOTIFY_BRN_MAX; /* brightness up */
else } else {
event = NOTIFY_BRN_MIN + 1; /* ... unchanged */ /*
* no change in brightness - already at min/max,
key = eepc_get_entry_by_scancode(event); * event will be desired value (or else ignored).
if (key) { */
switch (key->type) {
case KE_KEY:
input_report_key(ehotk->inputdev, key->keycode,
1);
input_sync(ehotk->inputdev);
input_report_key(ehotk->inputdev, key->keycode,
0);
input_sync(ehotk->inputdev);
break;
}
} }
} }
eeepc_input_notify(event);
} }
static int eeepc_register_rfkill_notifier(char *node) static int eeepc_register_rfkill_notifier(char *node)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment