aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorRick Koch <n1gp@hotmail.com>2006-08-05 00:32:24 -0400
committerDmitry Torokhov <dtor@insightbb.com>2006-08-05 00:32:24 -0400
commit4003dff41e65ad338a60dde90019bffcb5531fb6 (patch)
tree296bc2176ea6711ea3d54b83bb0b2befdcab5b31 /drivers/input
parentee4799997950e81437ef9055a4b104099e3272c4 (diff)
Input: add driver for Touchright serial touchscreens
Signed-off-by: Rick Koch <n1gp@hotmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/touchscreen/Kconfig12
-rw-r--r--drivers/input/touchscreen/Makefile1
-rw-r--r--drivers/input/touchscreen/touchright.c196
3 files changed, 209 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index fa038126d508..216db1229376 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -120,4 +120,16 @@ config TOUCHSCREEN_PENMOUNT
120 To compile this driver as a module, choose M here: the 120 To compile this driver as a module, choose M here: the
121 module will be called penmount. 121 module will be called penmount.
122 122
123config 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
123endif 135endif
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 72e7be8097a4..deda25e36807 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -13,3 +13,4 @@ obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
13obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o 13obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o
14obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o 14obj-$(CONFIG_TOUCHSCREEN_HP600) += hp680_ts_input.o
15obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o 15obj-$(CONFIG_TOUCHSCREEN_PENMOUNT) += penmount.o
16obj-$(CONFIG_TOUCHSCREEN_TOUCHRIGHT) += touchright.o
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
27MODULE_AUTHOR("Rick Koch <n1gp@hotmail.com>");
28MODULE_DESCRIPTION(DRIVER_DESC);
29MODULE_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
50struct 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
58static 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
87static 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
105static 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
157static 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
167MODULE_DEVICE_TABLE(serio, tr_serio_ids);
168
169static 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
184static int __init tr_init(void)
185{
186 serio_register_driver(&tr_drv);
187 return 0;
188}
189
190static void __exit tr_exit(void)
191{
192 serio_unregister_driver(&tr_drv);
193}
194
195module_init(tr_init);
196module_exit(tr_exit);