Skip to content

Commit

Permalink
eeepc-laptop: refactor notifications
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alan Jenkins authored and Len Brown committed Dec 9, 2009
1 parent 463b4e4 commit bf9598b
Showing 1 changed file with 39 additions and 32 deletions.
71 changes: 39 additions & 32 deletions drivers/platform/x86/eeepc-laptop.c
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,8 @@ static int eeepc_hotk_init(void)
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;
int old = bd->props.brightness;

Expand Down Expand Up @@ -731,50 +730,58 @@ static void eeepc_rfkill_notify(acpi_handle handle, u32 event, void *data)
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;

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;
int brn = -ENODEV;

if (event > ACPI_MAX_SYS_NOTIFY)
return;
if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX)
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) {
/* brightness-change events need special
* handling for conversion to key events
*/
if (brn < 0)
brn = event;
else
brn += NOTIFY_BRN_MIN;
if (event < brn)

if (event >= NOTIFY_BRN_MIN && event <= NOTIFY_BRN_MAX) {
int old_brightness, new_brightness;

/* Update backlight device. */
old_brightness = eeepc_backlight_notify();

/* Convert brightness event to keypress (obsolescent hack). */
new_brightness = event - NOTIFY_BRN_MIN;

if (new_brightness < old_brightness) {
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) {
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;
}
} else if (new_brightness > old_brightness) {
event = NOTIFY_BRN_MAX; /* brightness up */
} else {
/*
* no change in brightness - already at min/max,
* event will be desired value (or else ignored).
*/
}
}
eeepc_input_notify(event);
}

static int eeepc_register_rfkill_notifier(char *node)
Expand Down

0 comments on commit bf9598b

Please sign in to comment.