diff options
author | Arve Hjønnevåg <arve@android.com> | 2008-10-17 15:20:55 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2011-06-14 09:08:44 -0700 |
commit | ca5d75f61af6c00e8bd9f4063c73a206d23df394 (patch) | |
tree | 4f3912298dcbf84718a6063c7cb73af06a84e903 /drivers/input | |
parent | 04bbdfd360349b207bf1887742aadd7906b44bcc (diff) | |
download | kernel_samsung_aries-ca5d75f61af6c00e8bd9f4063c73a206d23df394.zip kernel_samsung_aries-ca5d75f61af6c00e8bd9f4063c73a206d23df394.tar.gz kernel_samsung_aries-ca5d75f61af6c00e8bd9f4063c73a206d23df394.tar.bz2 |
Input: Hold wake lock while event queue is not empty.
Allows userspace code to process input events while
the device appears to be asleep.
Signed-off-by: Arve Hjønnevåg <arve@android.com>
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/evdev.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/drivers/input/evdev.c b/drivers/input/evdev.c index be0921e..1f571d7 100644 --- a/drivers/input/evdev.c +++ b/drivers/input/evdev.c @@ -23,6 +23,7 @@ #include <linux/input.h> #include <linux/major.h> #include <linux/device.h> +#include <linux/wakelock.h> #include "input-compat.h" struct evdev { @@ -43,6 +44,7 @@ struct evdev_client { unsigned int tail; unsigned int packet_head; /* [future] position of the first element of next packet */ spinlock_t buffer_lock; /* protects access to buffer, head and tail */ + struct wake_lock wake_lock; struct fasync_struct *fasync; struct evdev *evdev; struct list_head node; @@ -59,6 +61,7 @@ static void evdev_pass_event(struct evdev_client *client, /* Interrupts are disabled, just acquire the lock. */ spin_lock(&client->buffer_lock); + wake_lock_timeout(&client->wake_lock, 5 * HZ); client->buffer[client->head++] = *event; client->head &= client->bufsize - 1; @@ -254,6 +257,7 @@ static int evdev_release(struct inode *inode, struct file *file) mutex_unlock(&evdev->mutex); evdev_detach_client(evdev, client); + wake_lock_destroy(&client->wake_lock); kfree(client); evdev_close_device(evdev); @@ -305,6 +309,7 @@ static int evdev_open(struct inode *inode, struct file *file) client->bufsize = bufsize; spin_lock_init(&client->buffer_lock); + wake_lock_init(&client->wake_lock, WAKE_LOCK_SUSPEND, "evdev"); client->evdev = evdev; evdev_attach_client(evdev, client); @@ -372,6 +377,8 @@ static int evdev_fetch_next_event(struct evdev_client *client, if (have_event) { *event = client->buffer[client->tail++]; client->tail &= client->bufsize - 1; + if (client->head == client->tail) + wake_unlock(&client->wake_lock); } spin_unlock_irq(&client->buffer_lock); |