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>
28 #define DRIVER_DESC "Hampshire serial touchscreen driver"
38 #define HAMPSHIRE_FORMAT_TOUCH_BIT 0x40
39 #define HAMPSHIRE_FORMAT_LENGTH 4
40 #define HAMPSHIRE_RESPONSE_BEGIN_BYTE 0x80
42 #define HAMPSHIRE_MIN_XC 0
43 #define HAMPSHIRE_MAX_XC 0x1000
44 #define HAMPSHIRE_MIN_YC 0
45 #define HAMPSHIRE_MAX_YC 0x1000
47 #define HAMPSHIRE_GET_XC(data) (((data[3] & 0x0c) >> 2) | (data[1] << 2) | ((data[0] & 0x38) << 6))
48 #define HAMPSHIRE_GET_YC(data) ((data[3] & 0x03) | (data[2] << 2) | ((data[0] & 0x07) << 9))
49 #define HAMPSHIRE_GET_TOUCHED(data) (HAMPSHIRE_FORMAT_TOUCH_BIT & data[0])
56 struct input_dev *
dev;
63 static void hampshire_process_data(
struct hampshire *phampshire)
65 struct input_dev *
dev = phampshire->
dev;
81 struct hampshire *phampshire = serio_get_drvdata(serio);
86 hampshire_process_data(phampshire);
88 dev_dbg(&serio->
dev,
"unknown/unsynchronized data: %x\n",
94 static void hampshire_disconnect(
struct serio *serio)
96 struct hampshire *phampshire = serio_get_drvdata(serio);
98 input_get_device(phampshire->
dev);
99 input_unregister_device(phampshire->
dev);
101 serio_set_drvdata(serio,
NULL);
102 input_put_device(phampshire->
dev);
112 static int hampshire_connect(
struct serio *serio,
struct serio_driver *drv)
115 struct input_dev *input_dev;
119 input_dev = input_allocate_device();
120 if (!phampshire || !input_dev) {
125 phampshire->
serio = serio;
126 phampshire->
dev = input_dev;
128 "%s/input0", serio->
phys);
130 input_dev->name =
"Hampshire Serial TouchScreen";
131 input_dev->phys = phampshire->
phys;
134 input_dev->id.product = 0;
135 input_dev->id.version = 0x0001;
136 input_dev->dev.parent = &serio->
dev;
139 input_set_abs_params(phampshire->
dev,
ABS_X,
141 input_set_abs_params(phampshire->
dev,
ABS_Y,
144 serio_set_drvdata(serio, phampshire);
150 err = input_register_device(phampshire->
dev);
157 fail2: serio_set_drvdata(serio,
NULL);
158 fail1: input_free_device(input_dev);
184 .id_table = hampshire_serio_ids,
185 .interrupt = hampshire_interrupt,
186 .connect = hampshire_connect,
187 .disconnect = hampshire_disconnect,