diff options
-rw-r--r-- | drivers/input/touchscreen/Kconfig | 12 | ||||
-rw-r--r-- | drivers/input/touchscreen/Makefile | 1 | ||||
-rw-r--r-- | drivers/input/touchscreen/penmount.c | 185 | ||||
-rw-r--r-- | include/linux/serio.h | 1 |
4 files changed, 199 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index b1b14f8d4dd6..fa038126d508 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -108,4 +108,16 @@ config TOUCHSCREEN_HP600 | |||
108 | To compile this driver as a module, choose M here: the | 108 | To compile this driver as a module, choose M here: the |
109 | module will be called hp680_ts_input. | 109 | module will be called hp680_ts_input. |
110 | 110 | ||
111 | config TOUCHSCREEN_PENMOUNT | ||
112 | tristate "Penmount serial touchscreen" | ||
113 | select SERIO | ||
114 | help | ||
115 | Say Y here if you have a Penmount serial touchscreen connected to | ||
116 | your system. | ||
117 | |||
118 | If unsure, say N. | ||
119 | |||
120 | To compile this driver as a module, choose M here: the | ||
121 | module will be called penmount. | ||
122 | |||
111 | endif | 123 | endif |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 5e5557c43121..72e7be8097a4 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -12,3 +12,4 @@ obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o | |||
12 | obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o | 12 | obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o |
13 | obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o | 13 | obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o |
14 | obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o | 14 | obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o |
15 | obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o | ||
diff --git a/drivers/input/touchscreen/penmount.c b/drivers/input/touchscreen/penmount.c new file mode 100644 index 000000000000..f7370109d43e --- /dev/null +++ b/drivers/input/touchscreen/penmount.c | |||
@@ -0,0 +1,185 @@ | |||
1 | /* | ||
2 | * Penmount serial touchscreen driver | ||
3 | * | ||
4 | * Copyright (c) 2006 Rick Koch <n1gp@hotmail.com> | ||
5 | * | ||
6 | * Based on ELO driver (drivers/input/touchscreen/elo.c) | ||
7 | * Copyright (c) 2004 Vojtech Pavlik | ||
8 | */ | ||
9 | |||
10 | /* | ||
11 | * This program is free software; you can redistribute it and/or modify it | ||
12 | * under the terms of the GNU General Public License version 2 as published | ||
13 | * by the Free Software Foundation. | ||
14 | */ | ||
15 | |||
16 | #include <linux/errno.h> | ||
17 | #include <linux/kernel.h> | ||
18 | #include <linux/module.h> | ||
19 | #include <linux/slab.h> | ||
20 | #include <linux/input.h> | ||
21 | #include <linux/serio.h> | ||
22 | #include <linux/init.h> | ||
23 | |||
24 | #define DRIVER_DESC "Penmount serial touchscreen driver" | ||
25 | |||
26 | MODULE_AUTHOR("Rick Koch <n1gp@hotmail.com>"); | ||
27 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
28 | MODULE_LICENSE("GPL"); | ||
29 | |||
30 | /* | ||
31 | * Definitions & global arrays. | ||
32 | */ | ||
33 | |||
34 | #define PM_MAX_LENGTH 5 | ||
35 | |||
36 | /* | ||
37 | * Per-touchscreen data. | ||
38 | */ | ||
39 | |||
40 | struct pm { | ||
41 | struct input_dev *dev; | ||
42 | struct serio *serio; | ||
43 | int idx; | ||
44 | unsigned char data[PM_MAX_LENGTH]; | ||
45 | char phys[32]; | ||
46 | }; | ||
47 | |||
48 | static irqreturn_t pm_interrupt(struct serio *serio, | ||
49 | unsigned char data, unsigned int flags, struct pt_regs *regs) | ||
50 | { | ||
51 | struct pm *pm = serio_get_drvdata(serio); | ||
52 | struct input_dev *dev = pm->dev; | ||
53 | |||
54 | pm->data[pm->idx] = data; | ||
55 | |||
56 | if (pm->data[0] & 0x80) { | ||
57 | if (PM_MAX_LENGTH == ++pm->idx) { | ||
58 | input_regs(dev, regs); | ||
59 | input_report_abs(dev, ABS_X, pm->data[2] * 128 + pm->data[1]); | ||
60 | input_report_abs(dev, ABS_Y, pm->data[4] * 128 + pm->data[3]); | ||
61 | input_report_key(dev, BTN_TOUCH, !!(pm->data[0] & 0x40)); | ||
62 | input_sync(dev); | ||
63 | pm->idx = 0; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | return IRQ_HANDLED; | ||
68 | } | ||
69 | |||
70 | /* | ||
71 | * pm_disconnect() is the opposite of pm_connect() | ||
72 | */ | ||
73 | |||
74 | static void pm_disconnect(struct serio *serio) | ||
75 | { | ||
76 | struct pm *pm = serio_get_drvdata(serio); | ||
77 | |||
78 | input_get_device(pm->dev); | ||
79 | input_unregister_device(pm->dev); | ||
80 | serio_close(serio); | ||
81 | serio_set_drvdata(serio, NULL); | ||
82 | input_put_device(pm->dev); | ||
83 | kfree(pm); | ||
84 | } | ||
85 | |||
86 | /* | ||
87 | * pm_connect() is the routine that is called when someone adds a | ||
88 | * new serio device that supports Gunze protocol and registers it as | ||
89 | * an input device. | ||
90 | */ | ||
91 | |||
92 | static int pm_connect(struct serio *serio, struct serio_driver *drv) | ||
93 | { | ||
94 | struct pm *pm; | ||
95 | struct input_dev *input_dev; | ||
96 | int err; | ||
97 | |||
98 | pm = kzalloc(sizeof(struct pm), GFP_KERNEL); | ||
99 | input_dev = input_allocate_device(); | ||
100 | if (!pm || !input_dev) { | ||
101 | err = -ENOMEM; | ||
102 | goto fail1; | ||
103 | } | ||
104 | |||
105 | pm->serio = serio; | ||
106 | pm->dev = input_dev; | ||
107 | snprintf(pm->phys, sizeof(pm->phys), "%s/input0", serio->phys); | ||
108 | |||
109 | input_dev->private = pm; | ||
110 | input_dev->name = "Penmount Serial TouchScreen"; | ||
111 | input_dev->phys = pm->phys; | ||
112 | input_dev->id.bustype = BUS_RS232; | ||
113 | input_dev->id.vendor = SERIO_PENMOUNT; | ||
114 | input_dev->id.product = 0; | ||
115 | input_dev->id.version = 0x0100; | ||
116 | input_dev->cdev.dev = &serio->dev; | ||
117 | |||
118 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
119 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
120 | input_set_abs_params(pm->dev, ABS_X, 0, 0x3ff, 0, 0); | ||
121 | input_set_abs_params(pm->dev, ABS_Y, 0, 0x3ff, 0, 0); | ||
122 | |||
123 | serio_set_drvdata(serio, pm); | ||
124 | |||
125 | err = serio_open(serio, drv); | ||
126 | if (err) | ||
127 | goto fail2; | ||
128 | |||
129 | err = input_register_device(pm->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(pm); | ||
139 | return err; | ||
140 | } | ||
141 | |||
142 | /* | ||
143 | * The serio driver structure. | ||
144 | */ | ||
145 | |||
146 | static struct serio_device_id pm_serio_ids[] = { | ||
147 | { | ||
148 | .type = SERIO_RS232, | ||
149 | .proto = SERIO_PENMOUNT, | ||
150 | .id = SERIO_ANY, | ||
151 | .extra = SERIO_ANY, | ||
152 | }, | ||
153 | { 0 } | ||
154 | }; | ||
155 | |||
156 | MODULE_DEVICE_TABLE(serio, pm_serio_ids); | ||
157 | |||
158 | static struct serio_driver pm_drv = { | ||
159 | .driver = { | ||
160 | .name = "penmountlpc", | ||
161 | }, | ||
162 | .description = DRIVER_DESC, | ||
163 | .id_table = pm_serio_ids, | ||
164 | .interrupt = pm_interrupt, | ||
165 | .connect = pm_connect, | ||
166 | .disconnect = pm_disconnect, | ||
167 | }; | ||
168 | |||
169 | /* | ||
170 | * The functions for inserting/removing us as a module. | ||
171 | */ | ||
172 | |||
173 | static int __init pm_init(void) | ||
174 | { | ||
175 | serio_register_driver(&pm_drv); | ||
176 | return 0; | ||
177 | } | ||
178 | |||
179 | static void __exit pm_exit(void) | ||
180 | { | ||
181 | serio_unregister_driver(&pm_drv); | ||
182 | } | ||
183 | |||
184 | module_init(pm_init); | ||
185 | module_exit(pm_exit); | ||
diff --git a/include/linux/serio.h b/include/linux/serio.h index 6348e8330897..ad546a0205c6 100644 --- a/include/linux/serio.h +++ b/include/linux/serio.h | |||
@@ -217,5 +217,6 @@ static inline void serio_unpin_driver(struct serio *serio) | |||
217 | #define SERIO_LKKBD 0x28 | 217 | #define SERIO_LKKBD 0x28 |
218 | #define SERIO_ELO 0x29 | 218 | #define SERIO_ELO 0x29 |
219 | #define SERIO_MICROTOUCH 0x30 | 219 | #define SERIO_MICROTOUCH 0x30 |
220 | #define SERIO_PENMOUNT 0x31 | ||
220 | 221 | ||
221 | #endif | 222 | #endif |