From: Vojtech Pavlik <vojtech@suse.cz>
To: Vojtech Pavlik <vojtech@suse.cz>
Cc: torvalds@transmeta.com, linux-kernel@vger.kernel.org
Subject: [patch] input: Implement device grabbing [1/13]
Date: Sat, 14 Jun 2003 22:35:13 +0200 [thread overview]
Message-ID: <20030614223513.A25948@ucw.cz> (raw)
Hi!
This is a batch of already very much overdue fixes and needed
improvements. The most significant changes are Synaptics pad support
(although that code will still develop a bit), and fixes and
quirk additions in USB HID driver.
You can pull this changeset from:
bk://kernel.bkbits.net/vojtech/input
===================================================================
ChangeSet@1.1215.104.18, 2003-06-09 13:45:46+02:00, warp@mercury.d2dc.net
input: Implement input device grabbing so that it is possible to steal
an input device from other handlers and have an exclusive access
to events.
drivers/input/evdev.c | 37 +++++++++++++++++++++++++++++++++++--
drivers/input/input.c | 27 ++++++++++++++++++++++++---
include/linux/input.h | 7 +++++++
3 files changed, 66 insertions(+), 5 deletions(-)
===================================================================
diff -Nru a/drivers/input/evdev.c b/drivers/input/evdev.c
--- a/drivers/input/evdev.c Sat Jun 14 22:21:24 2003
+++ b/drivers/input/evdev.c Sat Jun 14 22:21:24 2003
@@ -29,6 +29,7 @@
char name[16];
struct input_handle handle;
wait_queue_head_t wait;
+ struct evdev_list *grab;
struct list_head list;
};
@@ -48,7 +49,8 @@
struct evdev *evdev = handle->private;
struct evdev_list *list;
- list_for_each_entry(list, &evdev->list, node) {
+ if (evdev->grab) {
+ list = evdev->grab;
do_gettimeofday(&list->buffer[list->head].time);
list->buffer[list->head].type = type;
@@ -57,7 +59,17 @@
list->head = (list->head + 1) & (EVDEV_BUFFER_SIZE - 1);
kill_fasync(&list->fasync, SIGIO, POLL_IN);
- }
+ } else
+ list_for_each_entry(list, &evdev->list, node) {
+
+ do_gettimeofday(&list->buffer[list->head].time);
+ list->buffer[list->head].type = type;
+ list->buffer[list->head].code = code;
+ list->buffer[list->head].value = value;
+ list->head = (list->head + 1) & (EVDEV_BUFFER_SIZE - 1);
+
+ kill_fasync(&list->fasync, SIGIO, POLL_IN);
+ }
wake_up_interruptible(&evdev->wait);
}
@@ -88,6 +100,11 @@
{
struct evdev_list *list = file->private_data;
+ if (list->evdev->grab == list) {
+ input_release_device(&list->evdev->handle);
+ list->evdev->grab = NULL;
+ }
+
evdev_fasync(-1, file, 0);
list_del(&list->node);
@@ -256,6 +273,22 @@
if (put_user(dev->ff_effects_max, (int*) arg))
return -EFAULT;
return 0;
+
+ case EVIOCGRAB:
+ if (arg) {
+ if (evdev->grab)
+ return -EBUSY;
+ if (input_grab_device(&evdev->handle))
+ return -EBUSY;
+ evdev->grab = list;
+ return 0;
+ } else {
+ if (evdev->grab != list)
+ return -EINVAL;
+ input_release_device(&evdev->handle);
+ evdev->grab = NULL;
+ return 0;
+ }
default:
diff -Nru a/drivers/input/input.c b/drivers/input/input.c
--- a/drivers/input/input.c Sat Jun 14 22:21:24 2003
+++ b/drivers/input/input.c Sat Jun 14 22:21:24 2003
@@ -33,6 +33,8 @@
EXPORT_SYMBOL(input_unregister_device);
EXPORT_SYMBOL(input_register_handler);
EXPORT_SYMBOL(input_unregister_handler);
+EXPORT_SYMBOL(input_grab_device);
+EXPORT_SYMBOL(input_release_device);
EXPORT_SYMBOL(input_open_device);
EXPORT_SYMBOL(input_close_device);
EXPORT_SYMBOL(input_accept_process);
@@ -175,9 +177,12 @@
if (type != EV_SYN)
dev->sync = 0;
- list_for_each_entry(handle, &dev->h_list, d_node)
- if (handle->open)
- handle->handler->event(handle, type, code, value);
+ if (dev->grab)
+ dev->grab->handler->event(dev->grab, type, code, value);
+ else
+ list_for_each_entry(handle, &dev->h_list, d_node)
+ if (handle->open)
+ handle->handler->event(handle, type, code, value);
}
static void input_repeat_key(unsigned long data)
@@ -201,6 +206,21 @@
return 0;
}
+int input_grab_device(struct input_handle *handle)
+{
+ if (handle->dev->grab)
+ return -EBUSY;
+
+ handle->dev->grab = handle;
+ return 0;
+}
+
+void input_release_device(struct input_handle *handle)
+{
+ if (handle->dev->grab == handle)
+ handle->dev->grab = NULL;
+}
+
int input_open_device(struct input_handle *handle)
{
if (handle->dev->pm_dev)
@@ -221,6 +241,7 @@
void input_close_device(struct input_handle *handle)
{
+ input_release_device(handle);
if (handle->dev->pm_dev)
pm_dev_idle(handle->dev->pm_dev);
if (handle->dev->close)
diff -Nru a/include/linux/input.h b/include/linux/input.h
--- a/include/linux/input.h Sat Jun 14 22:21:24 2003
+++ b/include/linux/input.h Sat Jun 14 22:21:24 2003
@@ -77,6 +77,8 @@
#define EVIOCRMFF _IOW('E', 0x81, int) /* Erase a force effect */
#define EVIOCGEFFECTS _IOR('E', 0x84, int) /* Report number of effects playable at the same time */
+#define EVIOCGRAB _IOW('E', 0x90, int) /* Grab/Release device */
+
/*
* Event types
*/
@@ -798,6 +800,8 @@
int (*upload_effect)(struct input_dev *dev, struct ff_effect *effect);
int (*erase_effect)(struct input_dev *dev, int effect_id);
+ struct input_handle *grab;
+
struct list_head h_list;
struct list_head node;
};
@@ -887,6 +891,9 @@
void input_register_handler(struct input_handler *);
void input_unregister_handler(struct input_handler *);
+
+int input_grab_device(struct input_handle *);
+void input_release_device(struct input_handle *);
int input_open_device(struct input_handle *);
void input_close_device(struct input_handle *);
next reply other threads:[~2003-06-14 20:21 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-06-14 20:35 Vojtech Pavlik [this message]
2003-06-14 20:36 ` [patch] input: Fix sunkbd keybit bitfield filling [2/13] Vojtech Pavlik
2003-06-14 20:37 ` [patch] input: Implement HID quirk for A4Tech mice [3/13] Vojtech Pavlik
2003-06-14 20:39 ` [patch] input: Add hiragana/katakana keys to atkbd.c [4/13] Vojtech Pavlik
2003-06-14 20:40 ` [patch] input: Add PCI PS/2 controller support [5/13] Vojtech Pavlik
2003-06-14 20:40 ` [patch] input: Turn numlock ON on HP HIL machines [6/13] Vojtech Pavlik
2003-06-14 20:41 ` [patch] input: Add keys for HP HIL [7/13] Vojtech Pavlik
2003-06-14 20:42 ` [patch] input: Fix CLOCK_TICK_RATE usage ... [8/13] Vojtech Pavlik
2003-06-14 20:43 ` [patch] input: Fix i8042 interrupts on I2000 ia64 machines [9/13] Vojtech Pavlik
2003-06-14 20:44 ` [patch] input: Fix sending reports in USB HID [10/13] Vojtech Pavlik
2003-06-14 20:45 ` [patch] input: Fix hiddev_ioctl() [11/13] Vojtech Pavlik
2003-06-14 20:45 ` [patch] input: Fix minor errors in input-programming.txt [12/13] Vojtech Pavlik
2003-06-14 20:46 ` [patch] input: Add Synaptics touchpad support [13/13] Vojtech Pavlik
2003-06-14 21:05 ` [patch] input: Fix CLOCK_TICK_RATE usage ... [8/13] Riley Williams
2003-06-14 21:14 ` Vojtech Pavlik
2003-06-15 10:51 ` Riley Williams
2003-06-16 18:57 ` David Mosberger
2003-06-17 22:11 ` Riley Williams
2003-06-17 22:19 ` David Mosberger
2003-06-17 22:21 ` Vojtech Pavlik
2003-06-17 22:34 ` David Mosberger
2003-06-17 22:42 ` Vojtech Pavlik
2003-06-17 22:48 ` Russell King
2003-06-17 22:53 ` Vojtech Pavlik
2003-06-19 12:13 ` David Woodhouse
2003-06-19 14:19 ` Russell King
2003-06-17 23:08 ` David Mosberger
2003-06-17 23:14 ` Vojtech Pavlik
2003-06-17 23:24 ` David Mosberger
2003-06-17 23:31 ` Vojtech Pavlik
2003-06-18 0:47 ` george anzinger
2003-06-25 8:03 ` Riley Williams
2003-06-25 17:20 ` David Mosberger
2003-06-25 17:56 ` Riley Williams
2003-06-25 18:49 ` David Mosberger
2003-06-25 19:58 ` Vojtech Pavlik
2003-06-25 20:09 ` David Mosberger
2003-06-25 20:25 ` Assorted warnings while building 2.5.73 J.C. Wren
2003-06-18 14:47 ` [patch] input: Fix CLOCK_TICK_RATE usage ... [8/13] Hollis Blanchard
2003-06-18 18:50 ` David Mosberger
2003-06-17 22:21 ` Russell King
2003-06-17 22:38 ` Vojtech Pavlik
2003-06-18 0:46 ` george anzinger
2003-06-18 1:00 ` george anzinger
2003-06-14 20:51 ` [patch] input: Add PCI PS/2 controller support [5/13] Oliver Neukum
2003-06-14 21:03 ` Vojtech Pavlik
2003-06-14 21:04 ` Russell King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030614223513.A25948@ucw.cz \
--to=vojtech@suse.cz \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@transmeta.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox