diff options
Diffstat (limited to 'drivers/input')
-rw-r--r-- | drivers/input/keyboard/Kconfig | 11 | ||||
-rw-r--r-- | drivers/input/keyboard/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/keyboard/stowaway.c | 187 |
3 files changed, 199 insertions, 0 deletions
diff --git a/drivers/input/keyboard/Kconfig b/drivers/input/keyboard/Kconfig index a9dda56f62c4..ebd98d18cf0b 100644 --- a/drivers/input/keyboard/Kconfig +++ b/drivers/input/keyboard/Kconfig | |||
@@ -121,6 +121,17 @@ config KEYBOARD_NEWTON | |||
121 | To compile this driver as a module, choose M here: the | 121 | To compile this driver as a module, choose M here: the |
122 | module will be called newtonkbd. | 122 | module will be called newtonkbd. |
123 | 123 | ||
124 | config KEYBOARD_STOWAWAY | ||
125 | tristate "Stowaway keyboard" | ||
126 | select SERIO | ||
127 | help | ||
128 | Say Y here if you have a Stowaway keyboard on a serial port. | ||
129 | Stowaway compatible keyboards like Dicota Input-PDA keyboard | ||
130 | are also supported by this driver. | ||
131 | |||
132 | To compile this driver as a module, choose M here: the | ||
133 | module will be called stowaway. | ||
134 | |||
124 | config KEYBOARD_CORGI | 135 | config KEYBOARD_CORGI |
125 | tristate "Corgi keyboard" | 136 | tristate "Corgi keyboard" |
126 | depends on PXA_SHARPSL | 137 | depends on PXA_SHARPSL |
diff --git a/drivers/input/keyboard/Makefile b/drivers/input/keyboard/Makefile index 2708167ba175..bb4525e59df7 100644 --- a/drivers/input/keyboard/Makefile +++ b/drivers/input/keyboard/Makefile | |||
@@ -11,6 +11,7 @@ obj-$(CONFIG_KEYBOARD_XTKBD) += xtkbd.o | |||
11 | obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o | 11 | obj-$(CONFIG_KEYBOARD_AMIGA) += amikbd.o |
12 | obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o | 12 | obj-$(CONFIG_KEYBOARD_LOCOMO) += locomokbd.o |
13 | obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o | 13 | obj-$(CONFIG_KEYBOARD_NEWTON) += newtonkbd.o |
14 | obj-$(CONFIG_KEYBOARD_STOWAWAY) += stowaway.o | ||
14 | obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o | 15 | obj-$(CONFIG_KEYBOARD_CORGI) += corgikbd.o |
15 | obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o | 16 | obj-$(CONFIG_KEYBOARD_SPITZ) += spitzkbd.o |
16 | obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o | 17 | obj-$(CONFIG_KEYBOARD_HIL) += hil_kbd.o |
diff --git a/drivers/input/keyboard/stowaway.c b/drivers/input/keyboard/stowaway.c new file mode 100644 index 000000000000..04c54c57f25c --- /dev/null +++ b/drivers/input/keyboard/stowaway.c | |||
@@ -0,0 +1,187 @@ | |||
1 | /* | ||
2 | * Stowaway keyboard driver for Linux | ||
3 | */ | ||
4 | |||
5 | /* | ||
6 | * Copyright (c) 2006 Marek Vasut | ||
7 | * | ||
8 | * Based on Newton keyboard driver for Linux | ||
9 | * by Justin Cormack | ||
10 | */ | ||
11 | |||
12 | /* | ||
13 | * This program is free software; you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU General Public License as published by | ||
15 | * the Free Software Foundation; either version 2 of the License, or | ||
16 | * (at your option) any later version. | ||
17 | * | ||
18 | * This program is distributed in the hope that it will be useful, | ||
19 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
20 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
21 | * GNU General Public License for more details. | ||
22 | * | ||
23 | * You should have received a copy of the GNU General Public License | ||
24 | * along with this program; if not, write to the Free Software | ||
25 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
26 | * | ||
27 | * Should you need to contact me, the author, you can do so either by | ||
28 | * e-mail - mail your message to <marek.vasut@gmail.com>, or by paper mail: | ||
29 | * Marek Vasut, Liskovecka 559, Frydek-Mistek, 738 01 Czech Republic | ||
30 | */ | ||
31 | |||
32 | #include <linux/slab.h> | ||
33 | #include <linux/module.h> | ||
34 | #include <linux/input.h> | ||
35 | #include <linux/init.h> | ||
36 | #include <linux/serio.h> | ||
37 | |||
38 | #define DRIVER_DESC "Stowaway keyboard driver" | ||
39 | |||
40 | MODULE_AUTHOR("Marek Vasut <marek.vasut@gmail.com>"); | ||
41 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
42 | MODULE_LICENSE("GPL"); | ||
43 | |||
44 | #define SKBD_KEY_MASK 0x7f | ||
45 | #define SKBD_RELEASE 0x80 | ||
46 | |||
47 | static unsigned char skbd_keycode[128] = { | ||
48 | KEY_1, KEY_2, KEY_3, KEY_Z, KEY_4, KEY_5, KEY_6, KEY_7, | ||
49 | 0, KEY_Q, KEY_W, KEY_E, KEY_R, KEY_T, KEY_Y, KEY_GRAVE, | ||
50 | KEY_X, KEY_A, KEY_S, KEY_D, KEY_F, KEY_G, KEY_H, KEY_SPACE, | ||
51 | KEY_CAPSLOCK, KEY_TAB, KEY_LEFTCTRL, 0, 0, 0, 0, 0, | ||
52 | 0, 0, 0, KEY_LEFTALT, 0, 0, 0, 0, | ||
53 | 0, 0, 0, 0, KEY_C, KEY_V, KEY_B, KEY_N, | ||
54 | KEY_MINUS, KEY_EQUAL, KEY_BACKSPACE, KEY_HOME, KEY_8, KEY_9, KEY_0, KEY_ESC, | ||
55 | KEY_LEFTBRACE, KEY_RIGHTBRACE, KEY_BACKSLASH, KEY_END, KEY_U, KEY_I, KEY_O, KEY_P, | ||
56 | KEY_APOSTROPHE, KEY_ENTER, KEY_PAGEUP,0, KEY_J, KEY_K, KEY_L, KEY_SEMICOLON, | ||
57 | KEY_SLASH, KEY_UP, KEY_PAGEDOWN, 0,KEY_M, KEY_COMMA, KEY_DOT, KEY_INSERT, | ||
58 | KEY_DELETE, KEY_LEFT, KEY_DOWN, KEY_RIGHT, 0, 0, 0, | ||
59 | KEY_LEFTSHIFT, KEY_RIGHTSHIFT, 0, 0, 0, 0, 0, | ||
60 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
61 | 0, 0, 0, 0, 0, 0, 0, 0, | ||
62 | 0, KEY_F1, KEY_F2, KEY_F3, KEY_F4, KEY_F5, KEY_F6, KEY_F7, | ||
63 | KEY_F8, KEY_F9, KEY_F10, KEY_F11, KEY_F12, 0, 0, 0 | ||
64 | }; | ||
65 | |||
66 | struct skbd { | ||
67 | unsigned char keycode[128]; | ||
68 | struct input_dev *dev; | ||
69 | struct serio *serio; | ||
70 | char phys[32]; | ||
71 | }; | ||
72 | |||
73 | static irqreturn_t skbd_interrupt(struct serio *serio, unsigned char data, | ||
74 | unsigned int flags, struct pt_regs *regs) | ||
75 | { | ||
76 | struct skbd *skbd = serio_get_drvdata(serio); | ||
77 | struct input_dev *dev = skbd->dev; | ||
78 | |||
79 | if (skbd->keycode[data & SKBD_KEY_MASK]) { | ||
80 | input_regs(dev, regs); | ||
81 | input_report_key(dev, skbd->keycode[data & SKBD_KEY_MASK], | ||
82 | !(data & SKBD_RELEASE)); | ||
83 | input_sync(dev); | ||
84 | } | ||
85 | |||
86 | return IRQ_HANDLED; | ||
87 | } | ||
88 | |||
89 | static int skbd_connect(struct serio *serio, struct serio_driver *drv) | ||
90 | { | ||
91 | struct skbd *skbd; | ||
92 | struct input_dev *input_dev; | ||
93 | int err = -ENOMEM; | ||
94 | int i; | ||
95 | |||
96 | skbd = kzalloc(sizeof(struct skbd), GFP_KERNEL); | ||
97 | input_dev = input_allocate_device(); | ||
98 | if (!skbd || !input_dev) | ||
99 | goto fail1; | ||
100 | |||
101 | skbd->serio = serio; | ||
102 | skbd->dev = input_dev; | ||
103 | snprintf(skbd->phys, sizeof(skbd->phys), "%s/input0", serio->phys); | ||
104 | memcpy(skbd->keycode, skbd_keycode, sizeof(skbd->keycode)); | ||
105 | |||
106 | input_dev->name = "Stowaway Keyboard"; | ||
107 | input_dev->phys = skbd->phys; | ||
108 | input_dev->id.bustype = BUS_RS232; | ||
109 | input_dev->id.vendor = SERIO_STOWAWAY; | ||
110 | input_dev->id.product = 0x0001; | ||
111 | input_dev->id.version = 0x0100; | ||
112 | input_dev->cdev.dev = &serio->dev; | ||
113 | input_dev->private = skbd; | ||
114 | |||
115 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_REP); | ||
116 | input_dev->keycode = skbd->keycode; | ||
117 | input_dev->keycodesize = sizeof(unsigned char); | ||
118 | input_dev->keycodemax = ARRAY_SIZE(skbd_keycode); | ||
119 | for (i = 0; i < ARRAY_SIZE(skbd_keycode); i++) | ||
120 | set_bit(skbd_keycode[i], input_dev->keybit); | ||
121 | clear_bit(0, input_dev->keybit); | ||
122 | |||
123 | serio_set_drvdata(serio, skbd); | ||
124 | |||
125 | err = serio_open(serio, drv); | ||
126 | if (err) | ||
127 | goto fail2; | ||
128 | |||
129 | err = input_register_device(skbd->dev); | ||
130 | if (err) | ||
131 | goto fail3; | ||
132 | |||
133 | return 0; | ||
134 | |||
135 | fail3: serio_close(serio); | ||
136 | fail2: serio_set_drvdata(serio, NULL); | ||
137 | fail1: input_free_device(input_dev); | ||
138 | kfree(skbd); | ||
139 | return err; | ||
140 | } | ||
141 | |||
142 | static void skbd_disconnect(struct serio *serio) | ||
143 | { | ||
144 | struct skbd *skbd = serio_get_drvdata(serio); | ||
145 | |||
146 | serio_close(serio); | ||
147 | serio_set_drvdata(serio, NULL); | ||
148 | input_unregister_device(skbd->dev); | ||
149 | kfree(skbd); | ||
150 | } | ||
151 | |||
152 | static struct serio_device_id skbd_serio_ids[] = { | ||
153 | { | ||
154 | .type = SERIO_RS232, | ||
155 | .proto = SERIO_STOWAWAY, | ||
156 | .id = SERIO_ANY, | ||
157 | .extra = SERIO_ANY, | ||
158 | }, | ||
159 | { 0 } | ||
160 | }; | ||
161 | |||
162 | MODULE_DEVICE_TABLE(serio, skbd_serio_ids); | ||
163 | |||
164 | static struct serio_driver skbd_drv = { | ||
165 | .driver = { | ||
166 | .name = "stowaway", | ||
167 | }, | ||
168 | .description = DRIVER_DESC, | ||
169 | .id_table = skbd_serio_ids, | ||
170 | .interrupt = skbd_interrupt, | ||
171 | .connect = skbd_connect, | ||
172 | .disconnect = skbd_disconnect, | ||
173 | }; | ||
174 | |||
175 | static int __init skbd_init(void) | ||
176 | { | ||
177 | serio_register_driver(&skbd_drv); | ||
178 | return 0; | ||
179 | } | ||
180 | |||
181 | static void __exit skbd_exit(void) | ||
182 | { | ||
183 | serio_unregister_driver(&skbd_drv); | ||
184 | } | ||
185 | |||
186 | module_init(skbd_init); | ||
187 | module_exit(skbd_exit); | ||