9 #include <linux/kernel.h>
10 #include <linux/module.h>
11 #include <linux/slab.h>
12 #include <linux/input.h>
13 #include <linux/serio.h>
16 #define PACKET_LENGTH 5
18 struct input_dev *
dev;
25 static void tsc_process_data(
struct tsc_ser *ptsc)
27 struct input_dev *
dev = ptsc->
dev;
32 x = ((data[1] & 0x03) << 8) | data[2];
33 y = ((data[3] & 0x03) << 8) | data[4];
35 input_report_abs(dev,
ABS_X, x);
36 input_report_abs(dev,
ABS_Y, y);
45 struct tsc_ser *ptsc = serio_get_drvdata(serio);
46 struct input_dev *
dev = ptsc->
dev;
49 switch (ptsc->
idx++) {
51 if (
unlikely((data & 0x3e) != 0x10)) {
53 "unsynchronized packet start (0x%02x)\n", data);
55 }
else if (!(data & 0x01)) {
66 "unsynchronized data 0x%02x at offset %d\n",
73 tsc_process_data(ptsc);
81 static int tsc_connect(
struct serio *serio,
struct serio_driver *drv)
84 struct input_dev *input_dev;
88 input_dev = input_allocate_device();
89 if (!ptsc || !input_dev) {
95 ptsc->
dev = input_dev;
98 input_dev->name =
"TSC-10/25/40 Serial TouchScreen";
99 input_dev->phys = ptsc->
phys;
102 input_dev->id.product = 40;
103 input_dev->id.version = 0x0001;
104 input_dev->dev.parent = &serio->
dev;
108 input_set_abs_params(ptsc->
dev,
ABS_X, 0, 0x3ff, 0, 0);
109 input_set_abs_params(ptsc->
dev,
ABS_Y, 0, 0x3ff, 0, 0);
111 serio_set_drvdata(serio, ptsc);
117 error = input_register_device(ptsc->
dev);
126 serio_set_drvdata(serio,
NULL);
128 input_free_device(input_dev);
133 static void tsc_disconnect(
struct serio *serio)
135 struct tsc_ser *ptsc = serio_get_drvdata(serio);
139 input_unregister_device(ptsc->
dev);
142 serio_set_drvdata(serio,
NULL);
156 #define DRIVER_DESC "TSC-10/25/40 serial touchscreen driver"
163 .id_table = tsc_serio_ids,
164 .interrupt = tsc_interrupt,
165 .connect = tsc_connect,
166 .disconnect = tsc_disconnect,