aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorRichard Lemon <richard@codelemon.com>2008-06-26 10:10:41 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-06-30 09:37:32 -0400
commit3cadd2d98972f806165c634553ac4918b2b7920c (patch)
treef105fefd7b21131b6a5445ee8002f9441f061d5f /drivers/input
parent8a65c02f1dfda13ac2172f88f90f087330db82de (diff)
Input: Add driver for iNexio serial touchscreen.
Signed-off-by: Richard Lemon <richard@codelemon.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/inexio.c207
3 files changed, 220 insertions, 0 deletions
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig
index 030a89734855..4085791e7be2 100644
--- a/drivers/input/touchscreen/Kconfig
+++ b/drivers/input/touchscreen/Kconfig
@@ -103,6 +103,18 @@ config TOUCHSCREEN_MTOUCH
103 To compile this driver as a module, choose M here: the 103 To compile this driver as a module, choose M here: the
104 module will be called mtouch. 104 module will be called mtouch.
105 105
106config TOUCHSCREEN_INEXIO
107 tristate "iNexio serial touchscreens"
108 select SERIO
109 help
110 Say Y here if you have an iNexio serial touchscreen connected to
111 your system.
112
113 If unsure, say N.
114
115 To compile this driver as a module, choose M here: the
116 module will be called inexio.
117
106config TOUCHSCREEN_MK712 118config TOUCHSCREEN_MK712
107 tristate "ICS MicroClock MK712 touchscreen" 119 tristate "ICS MicroClock MK712 touchscreen"
108 help 120 help
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile
index 64a11f443dce..d63bcdcd28ec 100644
--- a/drivers/input/touchscreen/Makefile
+++ b/drivers/input/touchscreen/Makefile
@@ -12,6 +12,7 @@ obj-$(CONFIG_TOUCHSCREEN_CORGI) += corgi_ts.o
12obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o 12obj-$(CONFIG_TOUCHSCREEN_GUNZE) += gunze.o
13obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o 13obj-$(CONFIG_TOUCHSCREEN_ELO) += elo.o
14obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o 14obj-$(CONFIG_TOUCHSCREEN_FUJITSU) += fujitsu_ts.o
15obj-$(CONFIG_TOUCHSCREEN_INEXIO) += inexio.o
15obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o 16obj-$(CONFIG_TOUCHSCREEN_MIGOR) += migor_ts.o
16obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o 17obj-$(CONFIG_TOUCHSCREEN_MTOUCH) += mtouch.o
17obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o 18obj-$(CONFIG_TOUCHSCREEN_MK712) += mk712.o
diff --git a/drivers/input/touchscreen/inexio.c b/drivers/input/touchscreen/inexio.c
new file mode 100644
index 000000000000..192ade0a0fb9
--- /dev/null
+++ b/drivers/input/touchscreen/inexio.c
@@ -0,0 +1,207 @@
1/*
2 * iNexio serial touchscreen driver
3 *
4 * Copyright (c) 2008 Richard Lemon
5 * Based on the mtouch driver (c) Vojtech Pavlik and Dan Streetman
6 *
7 */
8
9/*
10 * This program is free software; you can redistribute it and/or modify it
11 * under the terms of the GNU General Public License version 2 as published by
12 * the Free Software Foundation.
13 */
14
15/*
16 * 2008/06/19 Richard Lemon <richard@codelemon.com>
17 * Copied mtouch.c and edited for iNexio protocol
18 */
19
20#include <linux/errno.h>
21#include <linux/kernel.h>
22#include <linux/module.h>
23#include <linux/slab.h>
24#include <linux/input.h>
25#include <linux/serio.h>
26#include <linux/init.h>
27
28#define DRIVER_DESC "iNexio serial touchscreen driver"
29
30MODULE_AUTHOR("Richard Lemon <richard@codelemon.com>");
31MODULE_DESCRIPTION(DRIVER_DESC);
32MODULE_LICENSE("GPL");
33
34/*
35 * Definitions & global arrays.
36 */
37
38#define INEXIO_FORMAT_TOUCH_BIT 0x01
39#define INEXIO_FORMAT_LENGTH 5
40#define INEXIO_RESPONSE_BEGIN_BYTE 0x80
41
42/* todo: check specs for max length of all responses */
43#define INEXIO_MAX_LENGTH 16
44
45#define INEXIO_MIN_XC 0
46#define INEXIO_MAX_XC 0x3fff
47#define INEXIO_MIN_YC 0
48#define INEXIO_MAX_YC 0x3fff
49
50#define INEXIO_GET_XC(data) (((data[1])<<7) | data[2])
51#define INEXIO_GET_YC(data) (((data[3])<<7) | data[4])
52#define INEXIO_GET_TOUCHED(data) (INEXIO_FORMAT_TOUCH_BIT & data[0])
53
54/*
55 * Per-touchscreen data.
56 */
57
58struct inexio {
59 struct input_dev *dev;
60 struct serio *serio;
61 int idx;
62 unsigned char data[INEXIO_MAX_LENGTH];
63 char phys[32];
64};
65
66static void inexio_process_data(struct inexio *pinexio)
67{
68 struct input_dev *dev = pinexio->dev;
69
70 if (INEXIO_FORMAT_LENGTH == ++pinexio->idx) {
71 input_report_abs(dev, ABS_X, INEXIO_GET_XC(pinexio->data));
72 input_report_abs(dev, ABS_Y, INEXIO_GET_YC(pinexio->data));
73 input_report_key(dev, BTN_TOUCH, INEXIO_GET_TOUCHED(pinexio->data));
74 input_sync(dev);
75
76 pinexio->idx = 0;
77 }
78}
79
80static irqreturn_t inexio_interrupt(struct serio *serio,
81 unsigned char data, unsigned int flags)
82{
83 struct inexio* pinexio = serio_get_drvdata(serio);
84
85 pinexio->data[pinexio->idx] = data;
86
87 if (INEXIO_RESPONSE_BEGIN_BYTE&pinexio->data[0])
88 inexio_process_data(pinexio);
89 else
90 printk(KERN_DEBUG "inexio.c: unknown/unsynchronized data from device, byte %x\n",pinexio->data[0]);
91
92 return IRQ_HANDLED;
93}
94
95/*
96 * inexio_disconnect() is the opposite of inexio_connect()
97 */
98
99static void inexio_disconnect(struct serio *serio)
100{
101 struct inexio* pinexio = serio_get_drvdata(serio);
102
103 input_get_device(pinexio->dev);
104 input_unregister_device(pinexio->dev);
105 serio_close(serio);
106 serio_set_drvdata(serio, NULL);
107 input_put_device(pinexio->dev);
108 kfree(pinexio);
109}
110
111/*
112 * inexio_connect() is the routine that is called when someone adds a
113 * new serio device that supports iNexio protocol and registers it as
114 * an input device. This is usually accomplished using inputattach.
115 */
116
117static int inexio_connect(struct serio *serio, struct serio_driver *drv)
118{
119 struct inexio *pinexio;
120 struct input_dev *input_dev;
121 int err;
122
123 pinexio = kzalloc(sizeof(struct inexio), GFP_KERNEL);
124 input_dev = input_allocate_device();
125 if (!pinexio || !input_dev) {
126 err = -ENOMEM;
127 goto fail1;
128 }
129
130 pinexio->serio = serio;
131 pinexio->dev = input_dev;
132 snprintf(pinexio->phys, sizeof(pinexio->phys), "%s/input0", serio->phys);
133
134 input_dev->name = "iNexio Serial TouchScreen";
135 input_dev->phys = pinexio->phys;
136 input_dev->id.bustype = BUS_RS232;
137 input_dev->id.vendor = SERIO_INEXIO;
138 input_dev->id.product = 0;
139 input_dev->id.version = 0x0001;
140 input_dev->dev.parent = &serio->dev;
141 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
142 input_dev->keybit[BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH);
143 input_set_abs_params(pinexio->dev, ABS_X, INEXIO_MIN_XC, INEXIO_MAX_XC, 0, 0);
144 input_set_abs_params(pinexio->dev, ABS_Y, INEXIO_MIN_YC, INEXIO_MAX_YC, 0, 0);
145
146 serio_set_drvdata(serio, pinexio);
147
148 err = serio_open(serio, drv);
149 if (err)
150 goto fail2;
151
152 err = input_register_device(pinexio->dev);
153 if (err)
154 goto fail3;
155
156 return 0;
157
158 fail3: serio_close(serio);
159 fail2: serio_set_drvdata(serio, NULL);
160 fail1: input_free_device(input_dev);
161 kfree(pinexio);
162 return err;
163}
164
165/*
166 * The serio driver structure.
167 */
168
169static struct serio_device_id inexio_serio_ids[] = {
170 {
171 .type = SERIO_RS232,
172 .proto = SERIO_INEXIO,
173 .id = SERIO_ANY,
174 .extra = SERIO_ANY,
175 },
176 { 0 }
177};
178
179MODULE_DEVICE_TABLE(serio, inexio_serio_ids);
180
181static struct serio_driver inexio_drv = {
182 .driver = {
183 .name = "inexio",
184 },
185 .description = DRIVER_DESC,
186 .id_table = inexio_serio_ids,
187 .interrupt = inexio_interrupt,
188 .connect = inexio_connect,
189 .disconnect = inexio_disconnect,
190};
191
192/*
193 * The functions for inserting/removing us as a module.
194 */
195
196static int __init inexio_init(void)
197{
198 return serio_register_driver(&inexio_drv);
199}
200
201static void __exit inexio_exit(void)
202{
203 serio_unregister_driver(&inexio_drv);
204}
205
206module_init(inexio_init);
207module_exit(inexio_exit);