diff options
Diffstat (limited to 'drivers/input/touchscreen')
-rw-r--r-- | drivers/input/touchscreen/Kconfig | 36 | ||||
-rw-r--r-- | drivers/input/touchscreen/Makefile | 3 | ||||
-rw-r--r-- | drivers/input/touchscreen/elo.c | 167 | ||||
-rw-r--r-- | drivers/input/touchscreen/penmount.c | 185 | ||||
-rw-r--r-- | drivers/input/touchscreen/touchright.c | 196 | ||||
-rw-r--r-- | drivers/input/touchscreen/touchwin.c | 203 |
6 files changed, 756 insertions, 34 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index b1b14f8d4dd6..9418bbe47072 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
@@ -108,4 +108,40 @@ 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 | |||
123 | config TOUCHSCREEN_TOUCHRIGHT | ||
124 | tristate "Touchright serial touchscreen" | ||
125 | select SERIO | ||
126 | help | ||
127 | Say Y here if you have a Touchright serial touchscreen connected to | ||
128 | your system. | ||
129 | |||
130 | If unsure, say N. | ||
131 | |||
132 | To compile this driver as a module, choose M here: the | ||
133 | module will be called touchright. | ||
134 | |||
135 | config TOUCHSCREEN_TOUCHWIN | ||
136 | tristate "Touchwin serial touchscreen" | ||
137 | select SERIO | ||
138 | help | ||
139 | Say Y here if you have a Touchwin serial touchscreen connected to | ||
140 | your system. | ||
141 | |||
142 | If unsure, say N. | ||
143 | |||
144 | To compile this driver as a module, choose M here: the | ||
145 | module will be called touchwin. | ||
146 | |||
111 | endif | 147 | endif |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 5e5557c43121..1abb8f10d608 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
@@ -12,3 +12,6 @@ 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 | ||
16 | obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o | ||
17 | obj-$(CONFIG_TOUCHSCREEN_TOUCHWIN) += touchwin.o | ||
diff --git a/drivers/input/touchscreen/elo.c b/drivers/input/touchscreen/elo.c index c86a2eb310fd..ab565335ee44 100644 --- a/drivers/input/touchscreen/elo.c +++ b/drivers/input/touchscreen/elo.c | |||
@@ -23,6 +23,7 @@ | |||
23 | #include <linux/input.h> | 23 | #include <linux/input.h> |
24 | #include <linux/serio.h> | 24 | #include <linux/serio.h> |
25 | #include <linux/init.h> | 25 | #include <linux/init.h> |
26 | #include <linux/ctype.h> | ||
26 | 27 | ||
27 | #define DRIVER_DESC "Elo serial touchscreen driver" | 28 | #define DRIVER_DESC "Elo serial touchscreen driver" |
28 | 29 | ||
@@ -34,7 +35,19 @@ MODULE_LICENSE("GPL"); | |||
34 | * Definitions & global arrays. | 35 | * Definitions & global arrays. |
35 | */ | 36 | */ |
36 | 37 | ||
37 | #define ELO_MAX_LENGTH 10 | 38 | #define ELO_MAX_LENGTH 10 |
39 | |||
40 | #define ELO10_PACKET_LEN 8 | ||
41 | #define ELO10_TOUCH 0x03 | ||
42 | #define ELO10_PRESSURE 0x80 | ||
43 | |||
44 | #define ELO10_LEAD_BYTE 'U' | ||
45 | |||
46 | #define ELO10_ID_CMD 'i' | ||
47 | |||
48 | #define ELO10_TOUCH_PACKET 'T' | ||
49 | #define ELO10_ACK_PACKET 'A' | ||
50 | #define ELI10_ID_PACKET 'I' | ||
38 | 51 | ||
39 | /* | 52 | /* |
40 | * Per-touchscreen data. | 53 | * Per-touchscreen data. |
@@ -43,51 +56,67 @@ MODULE_LICENSE("GPL"); | |||
43 | struct elo { | 56 | struct elo { |
44 | struct input_dev *dev; | 57 | struct input_dev *dev; |
45 | struct serio *serio; | 58 | struct serio *serio; |
59 | struct mutex cmd_mutex; | ||
60 | struct completion cmd_done; | ||
46 | int id; | 61 | int id; |
47 | int idx; | 62 | int idx; |
63 | unsigned char expected_packet; | ||
48 | unsigned char csum; | 64 | unsigned char csum; |
49 | unsigned char data[ELO_MAX_LENGTH]; | 65 | unsigned char data[ELO_MAX_LENGTH]; |
66 | unsigned char response[ELO10_PACKET_LEN]; | ||
50 | char phys[32]; | 67 | char phys[32]; |
51 | }; | 68 | }; |
52 | 69 | ||
53 | static void elo_process_data_10(struct elo* elo, unsigned char data, struct pt_regs *regs) | 70 | static void elo_process_data_10(struct elo *elo, unsigned char data, struct pt_regs *regs) |
54 | { | 71 | { |
55 | struct input_dev *dev = elo->dev; | 72 | struct input_dev *dev = elo->dev; |
56 | 73 | ||
57 | elo->csum += elo->data[elo->idx] = data; | 74 | elo->data[elo->idx] = data; |
58 | |||
59 | switch (elo->idx++) { | 75 | switch (elo->idx++) { |
60 | |||
61 | case 0: | 76 | case 0: |
62 | if (data != 'U') { | 77 | elo->csum = 0xaa; |
78 | if (data != ELO10_LEAD_BYTE) { | ||
79 | pr_debug("elo: unsynchronized data: 0x%02x\n", data); | ||
63 | elo->idx = 0; | 80 | elo->idx = 0; |
64 | elo->csum = 0; | ||
65 | } | ||
66 | break; | ||
67 | |||
68 | case 1: | ||
69 | if (data != 'T') { | ||
70 | elo->idx = 0; | ||
71 | elo->csum = 0; | ||
72 | } | 81 | } |
73 | break; | 82 | break; |
74 | 83 | ||
75 | case 9: | 84 | case 9: |
76 | if (elo->csum) { | 85 | elo->idx = 0; |
86 | if (data != elo->csum) { | ||
87 | pr_debug("elo: bad checksum: 0x%02x, expected 0x%02x\n", | ||
88 | data, elo->csum); | ||
89 | break; | ||
90 | } | ||
91 | if (elo->data[1] != elo->expected_packet) { | ||
92 | if (elo->data[1] != ELO10_TOUCH_PACKET) | ||
93 | pr_debug("elo: unexpected packet: 0x%02x\n", | ||
94 | elo->data[1]); | ||
95 | break; | ||
96 | } | ||
97 | if (likely(elo->data[1] == ELO10_TOUCH_PACKET)) { | ||
77 | input_regs(dev, regs); | 98 | input_regs(dev, regs); |
78 | input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); | 99 | input_report_abs(dev, ABS_X, (elo->data[4] << 8) | elo->data[3]); |
79 | input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); | 100 | input_report_abs(dev, ABS_Y, (elo->data[6] << 8) | elo->data[5]); |
80 | input_report_abs(dev, ABS_PRESSURE, (elo->data[8] << 8) | elo->data[7]); | 101 | if (elo->data[2] & ELO10_PRESSURE) |
81 | input_report_key(dev, BTN_TOUCH, elo->data[8] || elo->data[7]); | 102 | input_report_abs(dev, ABS_PRESSURE, |
103 | (elo->data[8] << 8) | elo->data[7]); | ||
104 | input_report_key(dev, BTN_TOUCH, elo->data[2] & ELO10_TOUCH); | ||
82 | input_sync(dev); | 105 | input_sync(dev); |
106 | } else if (elo->data[1] == ELO10_ACK_PACKET) { | ||
107 | if (elo->data[2] == '0') | ||
108 | elo->expected_packet = ELO10_TOUCH_PACKET; | ||
109 | complete(&elo->cmd_done); | ||
110 | } else { | ||
111 | memcpy(elo->response, &elo->data[1], ELO10_PACKET_LEN); | ||
112 | elo->expected_packet = ELO10_ACK_PACKET; | ||
83 | } | 113 | } |
84 | elo->idx = 0; | ||
85 | elo->csum = 0; | ||
86 | break; | 114 | break; |
87 | } | 115 | } |
116 | elo->csum += data; | ||
88 | } | 117 | } |
89 | 118 | ||
90 | static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_regs *regs) | 119 | static void elo_process_data_6(struct elo *elo, unsigned char data, struct pt_regs *regs) |
91 | { | 120 | { |
92 | struct input_dev *dev = elo->dev; | 121 | struct input_dev *dev = elo->dev; |
93 | 122 | ||
@@ -135,7 +164,7 @@ static void elo_process_data_6(struct elo* elo, unsigned char data, struct pt_re | |||
135 | } | 164 | } |
136 | } | 165 | } |
137 | 166 | ||
138 | static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_regs *regs) | 167 | static void elo_process_data_3(struct elo *elo, unsigned char data, struct pt_regs *regs) |
139 | { | 168 | { |
140 | struct input_dev *dev = elo->dev; | 169 | struct input_dev *dev = elo->dev; |
141 | 170 | ||
@@ -161,7 +190,7 @@ static void elo_process_data_3(struct elo* elo, unsigned char data, struct pt_re | |||
161 | static irqreturn_t elo_interrupt(struct serio *serio, | 190 | static irqreturn_t elo_interrupt(struct serio *serio, |
162 | unsigned char data, unsigned int flags, struct pt_regs *regs) | 191 | unsigned char data, unsigned int flags, struct pt_regs *regs) |
163 | { | 192 | { |
164 | struct elo* elo = serio_get_drvdata(serio); | 193 | struct elo *elo = serio_get_drvdata(serio); |
165 | 194 | ||
166 | switch(elo->id) { | 195 | switch(elo->id) { |
167 | case 0: | 196 | case 0: |
@@ -181,17 +210,81 @@ static irqreturn_t elo_interrupt(struct serio *serio, | |||
181 | return IRQ_HANDLED; | 210 | return IRQ_HANDLED; |
182 | } | 211 | } |
183 | 212 | ||
213 | static int elo_command_10(struct elo *elo, unsigned char *packet) | ||
214 | { | ||
215 | int rc = -1; | ||
216 | int i; | ||
217 | unsigned char csum = 0xaa + ELO10_LEAD_BYTE; | ||
218 | |||
219 | mutex_lock(&elo->cmd_mutex); | ||
220 | |||
221 | serio_pause_rx(elo->serio); | ||
222 | elo->expected_packet = toupper(packet[0]); | ||
223 | init_completion(&elo->cmd_done); | ||
224 | serio_continue_rx(elo->serio); | ||
225 | |||
226 | if (serio_write(elo->serio, ELO10_LEAD_BYTE)) | ||
227 | goto out; | ||
228 | |||
229 | for (i = 0; i < ELO10_PACKET_LEN; i++) { | ||
230 | csum += packet[i]; | ||
231 | if (serio_write(elo->serio, packet[i])) | ||
232 | goto out; | ||
233 | } | ||
234 | |||
235 | if (serio_write(elo->serio, csum)) | ||
236 | goto out; | ||
237 | |||
238 | wait_for_completion_timeout(&elo->cmd_done, HZ); | ||
239 | |||
240 | if (elo->expected_packet == ELO10_TOUCH_PACKET) { | ||
241 | /* We are back in reporting mode, the command was ACKed */ | ||
242 | memcpy(packet, elo->response, ELO10_PACKET_LEN); | ||
243 | rc = 0; | ||
244 | } | ||
245 | |||
246 | out: | ||
247 | mutex_unlock(&elo->cmd_mutex); | ||
248 | return rc; | ||
249 | } | ||
250 | |||
251 | static int elo_setup_10(struct elo *elo) | ||
252 | { | ||
253 | static const char *elo_types[] = { "Accu", "Dura", "Intelli", "Carroll" }; | ||
254 | struct input_dev *dev = elo->dev; | ||
255 | unsigned char packet[ELO10_PACKET_LEN] = { ELO10_ID_CMD }; | ||
256 | |||
257 | if (elo_command_10(elo, packet)) | ||
258 | return -1; | ||
259 | |||
260 | dev->id.version = (packet[5] << 8) | packet[4]; | ||
261 | |||
262 | input_set_abs_params(dev, ABS_X, 96, 4000, 0, 0); | ||
263 | input_set_abs_params(dev, ABS_Y, 96, 4000, 0, 0); | ||
264 | if (packet[3] & ELO10_PRESSURE) | ||
265 | input_set_abs_params(dev, ABS_PRESSURE, 0, 255, 0, 0); | ||
266 | |||
267 | printk(KERN_INFO "elo: %sTouch touchscreen, fw: %02x.%02x, " | ||
268 | "features: %x02x, controller: 0x%02x\n", | ||
269 | elo_types[(packet[1] -'0') & 0x03], | ||
270 | packet[5], packet[4], packet[3], packet[7]); | ||
271 | |||
272 | return 0; | ||
273 | } | ||
274 | |||
184 | /* | 275 | /* |
185 | * elo_disconnect() is the opposite of elo_connect() | 276 | * elo_disconnect() is the opposite of elo_connect() |
186 | */ | 277 | */ |
187 | 278 | ||
188 | static void elo_disconnect(struct serio *serio) | 279 | static void elo_disconnect(struct serio *serio) |
189 | { | 280 | { |
190 | struct elo* elo = serio_get_drvdata(serio); | 281 | struct elo *elo = serio_get_drvdata(serio); |
191 | 282 | ||
283 | input_get_device(elo->dev); | ||
192 | input_unregister_device(elo->dev); | 284 | input_unregister_device(elo->dev); |
193 | serio_close(serio); | 285 | serio_close(serio); |
194 | serio_set_drvdata(serio, NULL); | 286 | serio_set_drvdata(serio, NULL); |
287 | input_put_device(elo->dev); | ||
195 | kfree(elo); | 288 | kfree(elo); |
196 | } | 289 | } |
197 | 290 | ||
@@ -211,12 +304,15 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv) | |||
211 | input_dev = input_allocate_device(); | 304 | input_dev = input_allocate_device(); |
212 | if (!elo || !input_dev) { | 305 | if (!elo || !input_dev) { |
213 | err = -ENOMEM; | 306 | err = -ENOMEM; |
214 | goto fail; | 307 | goto fail1; |
215 | } | 308 | } |
216 | 309 | ||
217 | elo->serio = serio; | 310 | elo->serio = serio; |
218 | elo->id = serio->id.id; | 311 | elo->id = serio->id.id; |
219 | elo->dev = input_dev; | 312 | elo->dev = input_dev; |
313 | elo->expected_packet = ELO10_TOUCH_PACKET; | ||
314 | mutex_init(&elo->cmd_mutex); | ||
315 | init_completion(&elo->cmd_done); | ||
220 | snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys); | 316 | snprintf(elo->phys, sizeof(elo->phys), "%s/input0", serio->phys); |
221 | 317 | ||
222 | input_dev->private = elo; | 318 | input_dev->private = elo; |
@@ -231,12 +327,17 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv) | |||
231 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | 327 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); |
232 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | 328 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); |
233 | 329 | ||
330 | serio_set_drvdata(serio, elo); | ||
331 | err = serio_open(serio, drv); | ||
332 | if (err) | ||
333 | goto fail2; | ||
334 | |||
234 | switch (elo->id) { | 335 | switch (elo->id) { |
235 | 336 | ||
236 | case 0: /* 10-byte protocol */ | 337 | case 0: /* 10-byte protocol */ |
237 | input_set_abs_params(input_dev, ABS_X, 96, 4000, 0, 0); | 338 | if (elo_setup_10(elo)) |
238 | input_set_abs_params(input_dev, ABS_Y, 96, 4000, 0, 0); | 339 | goto fail3; |
239 | input_set_abs_params(input_dev, ABS_PRESSURE, 0, 255, 0, 0); | 340 | |
240 | break; | 341 | break; |
241 | 342 | ||
242 | case 1: /* 6-byte protocol */ | 343 | case 1: /* 6-byte protocol */ |
@@ -253,17 +354,15 @@ static int elo_connect(struct serio *serio, struct serio_driver *drv) | |||
253 | break; | 354 | break; |
254 | } | 355 | } |
255 | 356 | ||
256 | serio_set_drvdata(serio, elo); | 357 | err = input_register_device(elo->dev); |
257 | |||
258 | err = serio_open(serio, drv); | ||
259 | if (err) | 358 | if (err) |
260 | goto fail; | 359 | goto fail3; |
261 | 360 | ||
262 | input_register_device(elo->dev); | ||
263 | return 0; | 361 | return 0; |
264 | 362 | ||
265 | fail: serio_set_drvdata(serio, NULL); | 363 | fail3: serio_close(serio); |
266 | input_free_device(input_dev); | 364 | fail2: serio_set_drvdata(serio, NULL); |
365 | fail1: input_free_device(input_dev); | ||
267 | kfree(elo); | 366 | kfree(elo); |
268 | return err; | 367 | return err; |
269 | } | 368 | } |
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/drivers/input/touchscreen/touchright.c b/drivers/input/touchscreen/touchright.c new file mode 100644 index 000000000000..1c89fa538651 --- /dev/null +++ b/drivers/input/touchscreen/touchright.c | |||
@@ -0,0 +1,196 @@ | |||
1 | /* | ||
2 | * Touchright serial touchscreen driver | ||
3 | * | ||
4 | * Copyright (c) 2006 Rick Koch <n1gp@hotmail.com> | ||
5 | * | ||
6 | * Based on MicroTouch driver (drivers/input/touchscreen/mtouch.c) | ||
7 | * Copyright (c) 2004 Vojtech Pavlik | ||
8 | * and Dan Streetman <ddstreet@ieee.org> | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License version 2 as published | ||
14 | * by the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | #include <linux/errno.h> | ||
18 | #include <linux/kernel.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/slab.h> | ||
21 | #include <linux/input.h> | ||
22 | #include <linux/serio.h> | ||
23 | #include <linux/init.h> | ||
24 | |||
25 | #define DRIVER_DESC "Touchright serial touchscreen driver" | ||
26 | |||
27 | MODULE_AUTHOR("Rick Koch <n1gp@hotmail.com>"); | ||
28 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
29 | MODULE_LICENSE("GPL"); | ||
30 | |||
31 | /* | ||
32 | * Definitions & global arrays. | ||
33 | */ | ||
34 | |||
35 | #define TR_FORMAT_TOUCH_BIT 0x01 | ||
36 | #define TR_FORMAT_STATUS_BYTE 0x40 | ||
37 | #define TR_FORMAT_STATUS_MASK ~TR_FORMAT_TOUCH_BIT | ||
38 | |||
39 | #define TR_LENGTH 5 | ||
40 | |||
41 | #define TR_MIN_XC 0 | ||
42 | #define TR_MAX_XC 0x1ff | ||
43 | #define TR_MIN_YC 0 | ||
44 | #define TR_MAX_YC 0x1ff | ||
45 | |||
46 | /* | ||
47 | * Per-touchscreen data. | ||
48 | */ | ||
49 | |||
50 | struct tr { | ||
51 | struct input_dev *dev; | ||
52 | struct serio *serio; | ||
53 | int idx; | ||
54 | unsigned char data[TR_LENGTH]; | ||
55 | char phys[32]; | ||
56 | }; | ||
57 | |||
58 | static irqreturn_t tr_interrupt(struct serio *serio, | ||
59 | unsigned char data, unsigned int flags, struct pt_regs *regs) | ||
60 | { | ||
61 | struct tr *tr = serio_get_drvdata(serio); | ||
62 | struct input_dev *dev = tr->dev; | ||
63 | |||
64 | tr->data[tr->idx] = data; | ||
65 | |||
66 | if ((tr->data[0] & TR_FORMAT_STATUS_MASK) == TR_FORMAT_STATUS_BYTE) { | ||
67 | if (++tr->idx == TR_LENGTH) { | ||
68 | input_regs(dev, regs); | ||
69 | input_report_abs(dev, ABS_X, | ||
70 | (tr->data[1] << 5) | (tr->data[2] >> 1)); | ||
71 | input_report_abs(dev, ABS_Y, | ||
72 | (tr->data[3] << 5) | (tr->data[4] >> 1)); | ||
73 | input_report_key(dev, BTN_TOUCH, | ||
74 | tr->data[0] & TR_FORMAT_TOUCH_BIT); | ||
75 | input_sync(dev); | ||
76 | tr->idx = 0; | ||
77 | } | ||
78 | } | ||
79 | |||
80 | return IRQ_HANDLED; | ||
81 | } | ||
82 | |||
83 | /* | ||
84 | * tr_disconnect() is the opposite of tr_connect() | ||
85 | */ | ||
86 | |||
87 | static void tr_disconnect(struct serio *serio) | ||
88 | { | ||
89 | struct tr *tr = serio_get_drvdata(serio); | ||
90 | |||
91 | input_get_device(tr->dev); | ||
92 | input_unregister_device(tr->dev); | ||
93 | serio_close(serio); | ||
94 | serio_set_drvdata(serio, NULL); | ||
95 | input_put_device(tr->dev); | ||
96 | kfree(tr); | ||
97 | } | ||
98 | |||
99 | /* | ||
100 | * tr_connect() is the routine that is called when someone adds a | ||
101 | * new serio device that supports the Touchright protocol and registers it as | ||
102 | * an input device. | ||
103 | */ | ||
104 | |||
105 | static int tr_connect(struct serio *serio, struct serio_driver *drv) | ||
106 | { | ||
107 | struct tr *tr; | ||
108 | struct input_dev *input_dev; | ||
109 | int err; | ||
110 | |||
111 | tr = kzalloc(sizeof(struct tr), GFP_KERNEL); | ||
112 | input_dev = input_allocate_device(); | ||
113 | if (!tr || !input_dev) { | ||
114 | err = -ENOMEM; | ||
115 | goto fail1; | ||
116 | } | ||
117 | |||
118 | tr->serio = serio; | ||
119 | tr->dev = input_dev; | ||
120 | snprintf(tr->phys, sizeof(tr->phys), "%s/input0", serio->phys); | ||
121 | |||
122 | input_dev->private = tr; | ||
123 | input_dev->name = "Touchright Serial TouchScreen"; | ||
124 | input_dev->phys = tr->phys; | ||
125 | input_dev->id.bustype = BUS_RS232; | ||
126 | input_dev->id.vendor = SERIO_TOUCHRIGHT; | ||
127 | input_dev->id.product = 0; | ||
128 | input_dev->id.version = 0x0100; | ||
129 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
130 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
131 | input_set_abs_params(tr->dev, ABS_X, TR_MIN_XC, TR_MAX_XC, 0, 0); | ||
132 | input_set_abs_params(tr->dev, ABS_Y, TR_MIN_YC, TR_MAX_YC, 0, 0); | ||
133 | |||
134 | serio_set_drvdata(serio, tr); | ||
135 | |||
136 | err = serio_open(serio, drv); | ||
137 | if (err) | ||
138 | goto fail2; | ||
139 | |||
140 | err = input_register_device(tr->dev); | ||
141 | if (err) | ||
142 | goto fail3; | ||
143 | |||
144 | return 0; | ||
145 | |||
146 | fail3: serio_close(serio); | ||
147 | fail2: serio_set_drvdata(serio, NULL); | ||
148 | fail1: input_free_device(input_dev); | ||
149 | kfree(tr); | ||
150 | return err; | ||
151 | } | ||
152 | |||
153 | /* | ||
154 | * The serio driver structure. | ||
155 | */ | ||
156 | |||
157 | static struct serio_device_id tr_serio_ids[] = { | ||
158 | { | ||
159 | .type = SERIO_RS232, | ||
160 | .proto = SERIO_TOUCHRIGHT, | ||
161 | .id = SERIO_ANY, | ||
162 | .extra = SERIO_ANY, | ||
163 | }, | ||
164 | { 0 } | ||
165 | }; | ||
166 | |||
167 | MODULE_DEVICE_TABLE(serio, tr_serio_ids); | ||
168 | |||
169 | static struct serio_driver tr_drv = { | ||
170 | .driver = { | ||
171 | .name = "touchright", | ||
172 | }, | ||
173 | .description = DRIVER_DESC, | ||
174 | .id_table = tr_serio_ids, | ||
175 | .interrupt = tr_interrupt, | ||
176 | .connect = tr_connect, | ||
177 | .disconnect = tr_disconnect, | ||
178 | }; | ||
179 | |||
180 | /* | ||
181 | * The functions for inserting/removing us as a module. | ||
182 | */ | ||
183 | |||
184 | static int __init tr_init(void) | ||
185 | { | ||
186 | serio_register_driver(&tr_drv); | ||
187 | return 0; | ||
188 | } | ||
189 | |||
190 | static void __exit tr_exit(void) | ||
191 | { | ||
192 | serio_unregister_driver(&tr_drv); | ||
193 | } | ||
194 | |||
195 | module_init(tr_init); | ||
196 | module_exit(tr_exit); | ||
diff --git a/drivers/input/touchscreen/touchwin.c b/drivers/input/touchscreen/touchwin.c new file mode 100644 index 000000000000..a7b4c755958e --- /dev/null +++ b/drivers/input/touchscreen/touchwin.c | |||
@@ -0,0 +1,203 @@ | |||
1 | /* | ||
2 | * Touchwindow serial touchscreen driver | ||
3 | * | ||
4 | * Copyright (c) 2006 Rick Koch <n1gp@hotmail.com> | ||
5 | * | ||
6 | * Based on MicroTouch driver (drivers/input/touchscreen/mtouch.c) | ||
7 | * Copyright (c) 2004 Vojtech Pavlik | ||
8 | * and Dan Streetman <ddstreet@ieee.org> | ||
9 | */ | ||
10 | |||
11 | /* | ||
12 | * This program is free software; you can redistribute it and/or modify it | ||
13 | * under the terms of the GNU General Public License version 2 as published | ||
14 | * by the Free Software Foundation. | ||
15 | */ | ||
16 | |||
17 | /* | ||
18 | * 2005/02/19 Rick Koch: | ||
19 | * The Touchwindow I used is made by Edmark Corp. and | ||
20 | * constantly outputs a stream of 0's unless it is touched. | ||
21 | * It then outputs 3 bytes: X, Y, and a copy of Y. | ||
22 | */ | ||
23 | |||
24 | #include <linux/errno.h> | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/slab.h> | ||
28 | #include <linux/input.h> | ||
29 | #include <linux/serio.h> | ||
30 | #include <linux/init.h> | ||
31 | |||
32 | #define DRIVER_DESC "Touchwindow serial touchscreen driver" | ||
33 | |||
34 | MODULE_AUTHOR("Rick Koch <n1gp@hotmail.com>"); | ||
35 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
36 | MODULE_LICENSE("GPL"); | ||
37 | |||
38 | /* | ||
39 | * Definitions & global arrays. | ||
40 | */ | ||
41 | |||
42 | #define TW_LENGTH 3 | ||
43 | |||
44 | #define TW_MIN_XC 0 | ||
45 | #define TW_MAX_XC 0xff | ||
46 | #define TW_MIN_YC 0 | ||
47 | #define TW_MAX_YC 0xff | ||
48 | |||
49 | /* | ||
50 | * Per-touchscreen data. | ||
51 | */ | ||
52 | |||
53 | struct tw { | ||
54 | struct input_dev *dev; | ||
55 | struct serio *serio; | ||
56 | int idx; | ||
57 | int touched; | ||
58 | unsigned char data[TW_LENGTH]; | ||
59 | char phys[32]; | ||
60 | }; | ||
61 | |||
62 | static irqreturn_t tw_interrupt(struct serio *serio, | ||
63 | unsigned char data, unsigned int flags, struct pt_regs *regs) | ||
64 | { | ||
65 | struct tw *tw = serio_get_drvdata(serio); | ||
66 | struct input_dev *dev = tw->dev; | ||
67 | |||
68 | if (data) { /* touch */ | ||
69 | tw->touched = 1; | ||
70 | tw->data[tw->idx++] = data; | ||
71 | /* verify length and that the two Y's are the same */ | ||
72 | if (tw->idx == TW_LENGTH && tw->data[1] == tw->data[2]) { | ||
73 | input_regs(dev, regs); | ||
74 | input_report_abs(dev, ABS_X, tw->data[0]); | ||
75 | input_report_abs(dev, ABS_Y, tw->data[1]); | ||
76 | input_report_key(dev, BTN_TOUCH, 1); | ||
77 | input_sync(dev); | ||
78 | tw->idx = 0; | ||
79 | } | ||
80 | } else if (tw->touched) { /* untouch */ | ||
81 | input_report_key(dev, BTN_TOUCH, 0); | ||
82 | input_sync(dev); | ||
83 | tw->idx = 0; | ||
84 | tw->touched = 0; | ||
85 | } | ||
86 | |||
87 | return IRQ_HANDLED; | ||
88 | } | ||
89 | |||
90 | /* | ||
91 | * tw_disconnect() is the opposite of tw_connect() | ||
92 | */ | ||
93 | |||
94 | static void tw_disconnect(struct serio *serio) | ||
95 | { | ||
96 | struct tw *tw = serio_get_drvdata(serio); | ||
97 | |||
98 | input_get_device(tw->dev); | ||
99 | input_unregister_device(tw->dev); | ||
100 | serio_close(serio); | ||
101 | serio_set_drvdata(serio, NULL); | ||
102 | input_put_device(tw->dev); | ||
103 | kfree(tw); | ||
104 | } | ||
105 | |||
106 | /* | ||
107 | * tw_connect() is the routine that is called when someone adds a | ||
108 | * new serio device that supports the Touchwin protocol and registers it as | ||
109 | * an input device. | ||
110 | */ | ||
111 | |||
112 | static int tw_connect(struct serio *serio, struct serio_driver *drv) | ||
113 | { | ||
114 | struct tw *tw; | ||
115 | struct input_dev *input_dev; | ||
116 | int err; | ||
117 | |||
118 | tw = kzalloc(sizeof(struct tw), GFP_KERNEL); | ||
119 | input_dev = input_allocate_device(); | ||
120 | if (!tw || !input_dev) { | ||
121 | err = -ENOMEM; | ||
122 | goto fail1; | ||
123 | } | ||
124 | |||
125 | tw->serio = serio; | ||
126 | tw->dev = input_dev; | ||
127 | snprintf(tw->phys, sizeof(tw->phys), "%s/input0", serio->phys); | ||
128 | |||
129 | input_dev->private = tw; | ||
130 | input_dev->name = "Touchwindow Serial TouchScreen"; | ||
131 | input_dev->phys = tw->phys; | ||
132 | input_dev->id.bustype = BUS_RS232; | ||
133 | input_dev->id.vendor = SERIO_TOUCHWIN; | ||
134 | input_dev->id.product = 0; | ||
135 | input_dev->id.version = 0x0100; | ||
136 | input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); | ||
137 | input_dev->keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH); | ||
138 | input_set_abs_params(tw->dev, ABS_X, TW_MIN_XC, TW_MAX_XC, 0, 0); | ||
139 | input_set_abs_params(tw->dev, ABS_Y, TW_MIN_YC, TW_MAX_YC, 0, 0); | ||
140 | |||
141 | serio_set_drvdata(serio, tw); | ||
142 | |||
143 | err = serio_open(serio, drv); | ||
144 | if (err) | ||
145 | goto fail2; | ||
146 | |||
147 | err = input_register_device(tw->dev); | ||
148 | if (err) | ||
149 | goto fail3; | ||
150 | |||
151 | return 0; | ||
152 | |||
153 | fail3: serio_close(serio); | ||
154 | fail2: serio_set_drvdata(serio, NULL); | ||
155 | fail1: input_free_device(input_dev); | ||
156 | kfree(tw); | ||
157 | return err; | ||
158 | } | ||
159 | |||
160 | /* | ||
161 | * The serio driver structure. | ||
162 | */ | ||
163 | |||
164 | static struct serio_device_id tw_serio_ids[] = { | ||
165 | { | ||
166 | .type = SERIO_RS232, | ||
167 | .proto = SERIO_TOUCHWIN, | ||
168 | .id = SERIO_ANY, | ||
169 | .extra = SERIO_ANY, | ||
170 | }, | ||
171 | { 0 } | ||
172 | }; | ||
173 | |||
174 | MODULE_DEVICE_TABLE(serio, tw_serio_ids); | ||
175 | |||
176 | static struct serio_driver tw_drv = { | ||
177 | .driver = { | ||
178 | .name = "touchwin", | ||
179 | }, | ||
180 | .description = DRIVER_DESC, | ||
181 | .id_table = tw_serio_ids, | ||
182 | .interrupt = tw_interrupt, | ||
183 | .connect = tw_connect, | ||
184 | .disconnect = tw_disconnect, | ||
185 | }; | ||
186 | |||
187 | /* | ||
188 | * The functions for inserting/removing us as a module. | ||
189 | */ | ||
190 | |||
191 | static int __init tw_init(void) | ||
192 | { | ||
193 | serio_register_driver(&tw_drv); | ||
194 | return 0; | ||
195 | } | ||
196 | |||
197 | static void __exit tw_exit(void) | ||
198 | { | ||
199 | serio_unregister_driver(&tw_drv); | ||
200 | } | ||
201 | |||
202 | module_init(tw_init); | ||
203 | module_exit(tw_exit); | ||