aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/touchscreen/gunze.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:20:36 -0400
commit1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 (patch)
tree0bba044c4ce775e45a88a51686b5d9f90697ea9d /drivers/input/touchscreen/gunze.c
Linux-2.6.12-rc2v2.6.12-rc2
Initial git repository build. I'm not bothering with the full history, even though we have it. We can create a separate "historical" git archive of that later if we want to, and in the meantime it's about 3.2GB when imported into git - space that would just make the early git days unnecessarily complicated, when we don't have a lot of good infrastructure for it. Let it rip!
Diffstat (limited to 'drivers/input/touchscreen/gunze.c')
-rw-r--r--drivers/input/touchscreen/gunze.c205
1 files changed, 205 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/gunze.c b/drivers/input/touchscreen/gunze.c
new file mode 100644
index 000000000000..c9d0a153671c
--- /dev/null
+++ b/drivers/input/touchscreen/gunze.c
@@ -0,0 +1,205 @@
1/*
2 * $Id: gunze.c,v 1.12 2001/09/25 10:12:07 vojtech Exp $
3 *
4 * Copyright (c) 2000-2001 Vojtech Pavlik
5 */
6
7/*
8 * Gunze AHL-51S touchscreen driver for Linux
9 */
10
11/*
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25 *
26 * Should you need to contact me, the author, you can do so either by
27 * e-mail - mail your message to <vojtech@ucw.cz>, or by paper mail:
28 * Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
29 */
30
31#include <linux/errno.h>
32#include <linux/kernel.h>
33#include <linux/module.h>
34#include <linux/slab.h>
35#include <linux/input.h>
36#include <linux/serio.h>
37#include <linux/init.h>
38
39#define DRIVER_DESC "Gunze AHL-51S touchscreen driver"
40
41MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>");
42MODULE_DESCRIPTION(DRIVER_DESC);
43MODULE_LICENSE("GPL");
44
45/*
46 * Definitions & global arrays.
47 */
48
49#define GUNZE_MAX_LENGTH 10
50
51static char *gunze_name = "Gunze AHL-51S TouchScreen";
52
53/*
54 * Per-touchscreen data.
55 */
56
57struct gunze {
58 struct input_dev dev;
59 struct serio *serio;
60 int idx;
61 unsigned char data[GUNZE_MAX_LENGTH];
62 char phys[32];
63};
64
65static void gunze_process_packet(struct gunze* gunze, struct pt_regs *regs)
66{
67 struct input_dev *dev = &gunze->dev;
68
69 if (gunze->idx != GUNZE_MAX_LENGTH || gunze->data[5] != ',' ||
70 (gunze->data[0] != 'T' && gunze->data[0] != 'R')) {
71 gunze->data[10] = 0;
72 printk(KERN_WARNING "gunze.c: bad packet: >%s<\n", gunze->data);
73 return;
74 }
75
76 input_regs(dev, regs);
77 input_report_abs(dev, ABS_X, simple_strtoul(gunze->data + 1, NULL, 10));
78 input_report_abs(dev, ABS_Y, 1024 - simple_strtoul(gunze->data + 6, NULL, 10));
79 input_report_key(dev, BTN_TOUCH, gunze->data[0] == 'T');
80 input_sync(dev);
81}
82
83static irqreturn_t gunze_interrupt(struct serio *serio,
84 unsigned char data, unsigned int flags, struct pt_regs *regs)
85{
86 struct gunze* gunze = serio_get_drvdata(serio);
87
88 if (data == '\r') {
89 gunze_process_packet(gunze, regs);
90 gunze->idx = 0;
91 } else {
92 if (gunze->idx < GUNZE_MAX_LENGTH)
93 gunze->data[gunze->idx++] = data;
94 }
95 return IRQ_HANDLED;
96}
97
98/*
99 * gunze_disconnect() is the opposite of gunze_connect()
100 */
101
102static void gunze_disconnect(struct serio *serio)
103{
104 struct gunze* gunze = serio_get_drvdata(serio);
105
106 input_unregister_device(&gunze->dev);
107 serio_close(serio);
108 serio_set_drvdata(serio, NULL);
109 kfree(gunze);
110}
111
112/*
113 * gunze_connect() is the routine that is called when someone adds a
114 * new serio device that supports Gunze protocol and registers it as
115 * an input device.
116 */
117
118static int gunze_connect(struct serio *serio, struct serio_driver *drv)
119{
120 struct gunze *gunze;
121 int err;
122
123 if (!(gunze = kmalloc(sizeof(struct gunze), GFP_KERNEL)))
124 return -ENOMEM;
125
126 memset(gunze, 0, sizeof(struct gunze));
127
128 init_input_dev(&gunze->dev);
129 gunze->dev.evbit[0] = BIT(EV_KEY) | BIT(EV_ABS);
130 gunze->dev.keybit[LONG(BTN_TOUCH)] = BIT(BTN_TOUCH);
131 input_set_abs_params(&gunze->dev, ABS_X, 24, 1000, 0, 0);
132 input_set_abs_params(&gunze->dev, ABS_Y, 24, 1000, 0, 0);
133
134 gunze->serio = serio;
135
136 sprintf(gunze->phys, "%s/input0", serio->phys);
137
138 gunze->dev.private = gunze;
139 gunze->dev.name = gunze_name;
140 gunze->dev.phys = gunze->phys;
141 gunze->dev.id.bustype = BUS_RS232;
142 gunze->dev.id.vendor = SERIO_GUNZE;
143 gunze->dev.id.product = 0x0051;
144 gunze->dev.id.version = 0x0100;
145
146 serio_set_drvdata(serio, gunze);
147
148 err = serio_open(serio, drv);
149 if (err) {
150 serio_set_drvdata(serio, NULL);
151 kfree(gunze);
152 return err;
153 }
154
155 input_register_device(&gunze->dev);
156
157 printk(KERN_INFO "input: %s on %s\n", gunze_name, serio->phys);
158
159 return 0;
160}
161
162/*
163 * The serio driver structure.
164 */
165
166static struct serio_device_id gunze_serio_ids[] = {
167 {
168 .type = SERIO_RS232,
169 .proto = SERIO_GUNZE,
170 .id = SERIO_ANY,
171 .extra = SERIO_ANY,
172 },
173 { 0 }
174};
175
176MODULE_DEVICE_TABLE(serio, gunze_serio_ids);
177
178static struct serio_driver gunze_drv = {
179 .driver = {
180 .name = "gunze",
181 },
182 .description = DRIVER_DESC,
183 .id_table = gunze_serio_ids,
184 .interrupt = gunze_interrupt,
185 .connect = gunze_connect,
186 .disconnect = gunze_disconnect,
187};
188
189/*
190 * The functions for inserting/removing us as a module.
191 */
192
193static int __init gunze_init(void)
194{
195 serio_register_driver(&gunze_drv);
196 return 0;
197}
198
199static void __exit gunze_exit(void)
200{
201 serio_unregister_driver(&gunze_drv);
202}
203
204module_init(gunze_init);
205module_exit(gunze_exit);