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>
23 #include <linux/serio.h>
26 #define DRIVER_DESC "PenMount serial touchscreen driver"
37 #define PM_MAX_LENGTH 6
38 #define PM_MAX_MTSLOT 16
39 #define PM_3000_MTSLOT 2
40 #define PM_6250_MTSLOT 12
56 struct input_dev *
dev;
71 static void pm_mtevent(
struct pm *
pm,
struct input_dev *
input)
79 if (pm->
slots[i].active) {
93 static bool pm_checkpacket(
unsigned char *
packet)
98 for (i = 0; i < 5; i++)
101 return packet[5] == (
unsigned char)~(total & 0xff);
104 static void pm_parse_9000(
struct pm *
pm)
106 struct input_dev *
dev = pm->
dev;
109 input_report_abs(dev,
ABS_X, pm->
data[1] * 128 + pm->
data[2]);
110 input_report_abs(dev,
ABS_Y, pm->
data[3] * 128 + pm->
data[4]);
117 static void pm_parse_6000(
struct pm *pm)
119 struct input_dev *dev = pm->
dev;
122 if (pm_checkpacket(pm->
data)) {
123 input_report_abs(dev,
ABS_X,
125 input_report_abs(dev,
ABS_Y,
134 static void pm_parse_3000(
struct pm *pm)
136 struct input_dev *dev = pm->
dev;
139 if (pm_checkpacket(pm->
data)) {
140 int slotnum = pm->
data[0] & 0x0f;
141 pm->
slots[slotnum].active = pm->
data[0] & 0x30;
150 static void pm_parse_6250(
struct pm *pm)
152 struct input_dev *dev = pm->
dev;
155 if (pm_checkpacket(pm->
data)) {
156 int slotnum = pm->
data[0] & 0x0f;
157 pm->
slots[slotnum].active = pm->
data[0] & 0x40;
169 struct pm *pm = serio_get_drvdata(serio);
182 static void pm_disconnect(
struct serio *serio)
184 struct pm *pm = serio_get_drvdata(serio);
188 input_unregister_device(pm->
dev);
191 serio_set_drvdata(serio,
NULL);
200 static int pm_connect(
struct serio *serio,
struct serio_driver *drv)
203 struct input_dev *input_dev;
208 input_dev = input_allocate_device();
209 if (!pm || !input_dev) {
219 input_dev->name =
"PenMount Serial TouchScreen";
220 input_dev->phys = pm->
phys;
223 input_dev->id.product = 0;
224 input_dev->id.version = 0x0100;
225 input_dev->dev.parent = &serio->
dev;
230 switch (serio->
id.id) {
235 input_dev->id.product = 0x9000;
236 max_x = max_y = 0x3ff;
242 input_dev->id.product = 0x6000;
243 max_x = max_y = 0x3ff;
249 input_dev->id.product = 0x3000;
250 max_x = max_y = 0x7ff;
257 input_dev->id.product = 0x6250;
258 max_x = max_y = 0x3ff;
263 input_set_abs_params(pm->
dev,
ABS_X, 0, max_x, 0, 0);
264 input_set_abs_params(pm->
dev,
ABS_Y, 0, max_y, 0, 0);
268 input_set_abs_params(pm->
dev,
270 input_set_abs_params(pm->
dev,
274 serio_set_drvdata(serio, pm);
280 err = input_register_device(pm->
dev);
287 fail2: serio_set_drvdata(serio,
NULL);
288 fail1: input_free_device(input_dev);
311 .name =
"serio-penmount",
314 .id_table = pm_serio_ids,
315 .interrupt = pm_interrupt,
316 .connect = pm_connect,
317 .disconnect = pm_disconnect,