18 #include <linux/errno.h>
19 #include <linux/kernel.h>
20 #include <linux/module.h>
21 #include <linux/slab.h>
22 #include <linux/input.h>
23 #include <linux/serio.h>
26 #define DRIVER_DESC "MicroTouch serial touchscreen driver"
36 #define MTOUCH_FORMAT_TABLET_STATUS_BIT 0x80
37 #define MTOUCH_FORMAT_TABLET_TOUCH_BIT 0x40
38 #define MTOUCH_FORMAT_TABLET_LENGTH 5
39 #define MTOUCH_RESPONSE_BEGIN_BYTE 0x01
40 #define MTOUCH_RESPONSE_END_BYTE 0x0d
43 #define MTOUCH_MAX_LENGTH 16
45 #define MTOUCH_MIN_XC 0
46 #define MTOUCH_MAX_XC 0x3fff
47 #define MTOUCH_MIN_YC 0
48 #define MTOUCH_MAX_YC 0x3fff
50 #define MTOUCH_GET_XC(data) (((data[2])<<7) | data[1])
51 #define MTOUCH_GET_YC(data) (((data[4])<<7) | data[3])
52 #define MTOUCH_GET_TOUCHED(data) (MTOUCH_FORMAT_TABLET_TOUCH_BIT & data[0])
59 struct input_dev *
dev;
66 static void mtouch_process_format_tablet(
struct mtouch *
mtouch)
68 struct input_dev *
dev = mtouch->
dev;
80 static void mtouch_process_response(
struct mtouch *
mtouch)
94 struct mtouch* mtouch = serio_get_drvdata(serio);
99 mtouch_process_format_tablet(mtouch);
101 mtouch_process_response(mtouch);
103 printk(
KERN_DEBUG "mtouch.c: unknown/unsynchronized data from device, byte %x\n",mtouch->
data[0]);
112 static void mtouch_disconnect(
struct serio *serio)
114 struct mtouch* mtouch = serio_get_drvdata(serio);
116 input_get_device(mtouch->
dev);
117 input_unregister_device(mtouch->
dev);
119 serio_set_drvdata(serio,
NULL);
120 input_put_device(mtouch->
dev);
130 static int mtouch_connect(
struct serio *serio,
struct serio_driver *drv)
132 struct mtouch *mtouch;
133 struct input_dev *input_dev;
136 mtouch = kzalloc(
sizeof(
struct mtouch),
GFP_KERNEL);
137 input_dev = input_allocate_device();
138 if (!mtouch || !input_dev) {
143 mtouch->
serio = serio;
144 mtouch->
dev = input_dev;
147 input_dev->name =
"MicroTouch Serial TouchScreen";
148 input_dev->phys = mtouch->
phys;
151 input_dev->id.product = 0;
152 input_dev->id.version = 0x0100;
153 input_dev->dev.parent = &serio->
dev;
159 serio_set_drvdata(serio, mtouch);
165 err = input_register_device(mtouch->
dev);
172 fail2: serio_set_drvdata(serio,
NULL);
173 fail1: input_free_device(input_dev);
199 .id_table = mtouch_serio_ids,
200 .interrupt = mtouch_interrupt,
201 .connect = mtouch_connect,
202 .disconnect = mtouch_disconnect,