diff options
-rw-r--r-- | drivers/hid/Kconfig | 21 | ||||
-rw-r--r-- | drivers/hid/Makefile | 1 | ||||
-rw-r--r-- | drivers/hid/uhid.c | 88 |
3 files changed, 110 insertions, 0 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig index e9c68fedfcff..8cca0af2dbd1 100644 --- a/drivers/hid/Kconfig +++ b/drivers/hid/Kconfig | |||
@@ -59,6 +59,27 @@ config HIDRAW | |||
59 | 59 | ||
60 | If unsure, say Y. | 60 | If unsure, say Y. |
61 | 61 | ||
62 | config UHID | ||
63 | tristate "User-space I/O driver support for HID subsystem" | ||
64 | depends on HID | ||
65 | default n | ||
66 | ---help--- | ||
67 | Say Y here if you want to provide HID I/O Drivers from user-space. | ||
68 | This allows to write I/O drivers in user-space and feed the data from | ||
69 | the device into the kernel. The kernel parses the HID reports, loads the | ||
70 | corresponding HID Device Driver or provides input devices on top of your | ||
71 | user-space device. | ||
72 | |||
73 | This driver cannot be used to parse HID-reports in user-space and write | ||
74 | special HID-drivers. You should use hidraw for that. | ||
75 | Instead, this driver allows to write the transport-layer driver in | ||
76 | user-space like USB-HID and Bluetooth-HID do in kernel-space. | ||
77 | |||
78 | If unsure, say N. | ||
79 | |||
80 | To compile this driver as a module, choose M here: the | ||
81 | module will be called uhid. | ||
82 | |||
62 | source "drivers/hid/usbhid/Kconfig" | 83 | source "drivers/hid/usbhid/Kconfig" |
63 | 84 | ||
64 | menu "Special HID drivers" | 85 | menu "Special HID drivers" |
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile index ca6cc9f0485c..d7061928325e 100644 --- a/drivers/hid/Makefile +++ b/drivers/hid/Makefile | |||
@@ -8,6 +8,7 @@ ifdef CONFIG_DEBUG_FS | |||
8 | endif | 8 | endif |
9 | 9 | ||
10 | obj-$(CONFIG_HID) += hid.o | 10 | obj-$(CONFIG_HID) += hid.o |
11 | obj-$(CONFIG_UHID) += uhid.o | ||
11 | 12 | ||
12 | obj-$(CONFIG_HID_GENERIC) += hid-generic.o | 13 | obj-$(CONFIG_HID_GENERIC) += hid-generic.o |
13 | 14 | ||
diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c new file mode 100644 index 000000000000..5b02d6cb0e60 --- /dev/null +++ b/drivers/hid/uhid.c | |||
@@ -0,0 +1,88 @@ | |||
1 | /* | ||
2 | * User-space I/O driver support for HID subsystem | ||
3 | * Copyright (c) 2012 David Herrmann | ||
4 | */ | ||
5 | |||
6 | /* | ||
7 | * This program is free software; you can redistribute it and/or modify it | ||
8 | * under the terms of the GNU General Public License as published by the Free | ||
9 | * Software Foundation; either version 2 of the License, or (at your option) | ||
10 | * any later version. | ||
11 | */ | ||
12 | |||
13 | #include <linux/atomic.h> | ||
14 | #include <linux/device.h> | ||
15 | #include <linux/fs.h> | ||
16 | #include <linux/hid.h> | ||
17 | #include <linux/input.h> | ||
18 | #include <linux/miscdevice.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/mutex.h> | ||
21 | #include <linux/poll.h> | ||
22 | #include <linux/sched.h> | ||
23 | #include <linux/spinlock.h> | ||
24 | #include <linux/uhid.h> | ||
25 | #include <linux/wait.h> | ||
26 | |||
27 | #define UHID_NAME "uhid" | ||
28 | |||
29 | static struct miscdevice uhid_misc; | ||
30 | |||
31 | static int uhid_char_open(struct inode *inode, struct file *file) | ||
32 | { | ||
33 | return 0; | ||
34 | } | ||
35 | |||
36 | static int uhid_char_release(struct inode *inode, struct file *file) | ||
37 | { | ||
38 | return 0; | ||
39 | } | ||
40 | |||
41 | static ssize_t uhid_char_read(struct file *file, char __user *buffer, | ||
42 | size_t count, loff_t *ppos) | ||
43 | { | ||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | static ssize_t uhid_char_write(struct file *file, const char __user *buffer, | ||
48 | size_t count, loff_t *ppos) | ||
49 | { | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | static unsigned int uhid_char_poll(struct file *file, poll_table *wait) | ||
54 | { | ||
55 | return 0; | ||
56 | } | ||
57 | |||
58 | static const struct file_operations uhid_fops = { | ||
59 | .owner = THIS_MODULE, | ||
60 | .open = uhid_char_open, | ||
61 | .release = uhid_char_release, | ||
62 | .read = uhid_char_read, | ||
63 | .write = uhid_char_write, | ||
64 | .poll = uhid_char_poll, | ||
65 | .llseek = no_llseek, | ||
66 | }; | ||
67 | |||
68 | static struct miscdevice uhid_misc = { | ||
69 | .fops = &uhid_fops, | ||
70 | .minor = MISC_DYNAMIC_MINOR, | ||
71 | .name = UHID_NAME, | ||
72 | }; | ||
73 | |||
74 | static int __init uhid_init(void) | ||
75 | { | ||
76 | return misc_register(&uhid_misc); | ||
77 | } | ||
78 | |||
79 | static void __exit uhid_exit(void) | ||
80 | { | ||
81 | misc_deregister(&uhid_misc); | ||
82 | } | ||
83 | |||
84 | module_init(uhid_init); | ||
85 | module_exit(uhid_exit); | ||
86 | MODULE_LICENSE("GPL"); | ||
87 | MODULE_AUTHOR("David Herrmann <dh.herrmann@gmail.com>"); | ||
88 | MODULE_DESCRIPTION("User-space I/O driver support for HID subsystem"); | ||