aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorStephane Chatty <chatty@lii-enac.fr>2010-04-10 10:43:08 -0400
committerJiri Kosina <jkosina@suse.cz>2010-04-10 15:28:35 -0400
commit0c3910c255d3f9caeef4ebad5d5a1156a2d33f69 (patch)
tree8b0cbad6e52b319db1297add12ba40e377f3d0f3 /drivers/hid
parentab195c58b864802c15e494f06ae109413e12d50b (diff)
HID: add support for the eGalax dual-touch panel
Added support for the eGalax dual-touch panel, found on the Asus EeePC T101MT Signed-off-by: Stephane Chatty <chatty@enac.fr> Tested-by: Philipp Merkel <linux@philmerk.de> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/Kconfig6
-rw-r--r--drivers/hid/Makefile1
-rw-r--r--drivers/hid/hid-core.c1
-rw-r--r--drivers/hid/hid-egalax.c280
-rw-r--r--drivers/hid/hid-ids.h3
5 files changed, 291 insertions, 0 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 71d4c0703629..dabf3b67f489 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -122,6 +122,12 @@ config DRAGONRISE_FF
122 Say Y here if you want to enable force feedback support for DragonRise Inc. 122 Say Y here if you want to enable force feedback support for DragonRise Inc.
123 game controllers. 123 game controllers.
124 124
125config HID_EGALAX
126 tristate "eGalax multi-touch panel"
127 depends on USB_HID
128 ---help---
129 Support for the eGalax dual-touch panel
130
125config HID_EZKEY 131config HID_EZKEY
126 tristate "Ezkey" if EMBEDDED 132 tristate "Ezkey" if EMBEDDED
127 depends on USB_HID 133 depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 0b2618f092ca..19dae07eb14a 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -30,6 +30,7 @@ obj-$(CONFIG_HID_CHERRY) += hid-cherry.o
30obj-$(CONFIG_HID_CHICONY) += hid-chicony.o 30obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
31obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o 31obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
32obj-$(CONFIG_HID_DRAGONRISE) += hid-drff.o 32obj-$(CONFIG_HID_DRAGONRISE) += hid-drff.o
33obj-$(CONFIG_HID_EGALAX) += hid-egalax.o
33obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o 34obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
34obj-$(CONFIG_HID_GYRATION) += hid-gyration.o 35obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
35obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o 36obj-$(CONFIG_HID_KENSINGTON) += hid-kensington.o
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 2e2aa759d230..0bbf59493876 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -1302,6 +1302,7 @@ static const struct hid_device_id hid_blacklist[] = {
1302 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) }, 1302 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_3) },
1303 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) }, 1303 { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_MOUSE) },
1304 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) }, 1304 { HID_USB_DEVICE(USB_VENDOR_ID_DRAGONRISE, 0x0006) },
1305 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV, USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
1305 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) }, 1306 { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
1306 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) }, 1307 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
1307 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) }, 1308 { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PCS_ADAPTOR) },
diff --git a/drivers/hid/hid-egalax.c b/drivers/hid/hid-egalax.c
new file mode 100644
index 000000000000..8b48d5a07179
--- /dev/null
+++ b/drivers/hid/hid-egalax.c
@@ -0,0 +1,280 @@
1/*
2 * HID driver for eGalax dual-touch panels
3 *
4 * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr>
5 *
6 */
7
8/*
9 * This program is free software; you can redistribute it and/or modify it
10 * under the terms of the GNU General Public License as published by the Free
11 * Software Foundation; either version 2 of the License, or (at your option)
12 * any later version.
13 */
14
15#include <linux/device.h>
16#include <linux/hid.h>
17#include <linux/module.h>
18#include <linux/usb.h>
19#include "usbhid/usbhid.h"
20
21MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
22MODULE_DESCRIPTION("eGalax dual-touch panel");
23MODULE_LICENSE("GPL");
24
25#include "hid-ids.h"
26
27struct egalax_data {
28 __u16 x, y, z;
29 __u8 id;
30 bool first; /* is this the first finger in the frame? */
31 bool valid; /* valid finger data, or just placeholder? */
32 bool activity; /* at least one active finger previously? */
33 __u16 lastx, lasty; /* latest valid (x, y) in the frame */
34};
35
36static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi,
37 struct hid_field *field, struct hid_usage *usage,
38 unsigned long **bit, int *max)
39{
40 switch (usage->hid & HID_USAGE_PAGE) {
41
42 case HID_UP_GENDESK:
43 switch (usage->hid) {
44 case HID_GD_X:
45 hid_map_usage(hi, usage, bit, max,
46 EV_ABS, ABS_MT_POSITION_X);
47 /* touchscreen emulation */
48 input_set_abs_params(hi->input, ABS_X,
49 field->logical_minimum,
50 field->logical_maximum, 0, 0);
51 return 1;
52 case HID_GD_Y:
53 hid_map_usage(hi, usage, bit, max,
54 EV_ABS, ABS_MT_POSITION_Y);
55 /* touchscreen emulation */
56 input_set_abs_params(hi->input, ABS_Y,
57 field->logical_minimum,
58 field->logical_maximum, 0, 0);
59 return 1;
60 }
61 return 0;
62
63 case HID_UP_DIGITIZER:
64 switch (usage->hid) {
65 case HID_DG_TIPSWITCH:
66 /* touchscreen emulation */
67 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
68 return 1;
69 case HID_DG_INRANGE:
70 case HID_DG_CONFIDENCE:
71 case HID_DG_CONTACTCOUNT:
72 case HID_DG_CONTACTMAX:
73 return -1;
74 case HID_DG_CONTACTID:
75 hid_map_usage(hi, usage, bit, max,
76 EV_ABS, ABS_MT_TRACKING_ID);
77 return 1;
78 case HID_DG_TIPPRESSURE:
79 hid_map_usage(hi, usage, bit, max,
80 EV_ABS, ABS_MT_PRESSURE);
81 return 1;
82 }
83 return 0;
84 }
85
86 /* ignore others (from other reports we won't get anyway) */
87 return -1;
88}
89
90static int egalax_input_mapped(struct hid_device *hdev, struct hid_input *hi,
91 struct hid_field *field, struct hid_usage *usage,
92 unsigned long **bit, int *max)
93{
94 if (usage->type == EV_KEY || usage->type == EV_ABS)
95 clear_bit(usage->code, *bit);
96
97 return 0;
98}
99
100/*
101 * this function is called when a whole finger has been parsed,
102 * so that it can decide what to send to the input layer.
103 */
104static void egalax_filter_event(struct egalax_data *td, struct input_dev *input)
105{
106 td->first = !td->first; /* touchscreen emulation */
107
108 if (td->valid) {
109 /* emit multitouch events */
110 input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id);
111 input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x);
112 input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y);
113 input_event(input, EV_ABS, ABS_MT_PRESSURE, td->z);
114
115 input_mt_sync(input);
116
117 /*
118 * touchscreen emulation: store (x, y) as
119 * the last valid values in this frame
120 */
121 td->lastx = td->x;
122 td->lasty = td->y;
123 }
124
125 /*
126 * touchscreen emulation: if this is the second finger and at least
127 * one in this frame is valid, the latest valid in the frame is
128 * the oldest on the panel, the one we want for single touch
129 */
130 if (!td->first && td->activity) {
131 input_event(input, EV_ABS, ABS_X, td->lastx);
132 input_event(input, EV_ABS, ABS_Y, td->lasty);
133 }
134
135 if (!td->valid) {
136 /*
137 * touchscreen emulation: if the first finger is invalid
138 * and there previously was finger activity, this is a release
139 */
140 if (td->first && td->activity) {
141 input_event(input, EV_KEY, BTN_TOUCH, 0);
142 td->activity = false;
143 }
144 return;
145 }
146
147
148 /* touchscreen emulation: if no previous activity, emit touch event */
149 if (!td->activity) {
150 input_event(input, EV_KEY, BTN_TOUCH, 1);
151 td->activity = true;
152 }
153}
154
155
156static int egalax_event(struct hid_device *hid, struct hid_field *field,
157 struct hid_usage *usage, __s32 value)
158{
159 struct egalax_data *td = hid_get_drvdata(hid);
160
161 if (hid->claimed & HID_CLAIMED_INPUT) {
162 struct input_dev *input = field->hidinput->input;
163
164 switch (usage->hid) {
165 case HID_DG_INRANGE:
166 case HID_DG_CONFIDENCE:
167 /* avoid interference from generic hidinput handling */
168 break;
169 case HID_DG_TIPSWITCH:
170 td->valid = value;
171 break;
172 case HID_DG_TIPPRESSURE:
173 td->z = value;
174 break;
175 case HID_DG_CONTACTID:
176 td->id = value;
177 break;
178 case HID_GD_X:
179 td->x = value;
180 break;
181 case HID_GD_Y:
182 td->y = value;
183 /* this is the last field in a finger */
184 egalax_filter_event(td, input);
185 break;
186 case HID_DG_CONTACTCOUNT:
187 /* touch emulation: this is the last field in a frame */
188 td->first = false;
189 break;
190
191 default:
192 /* fallback to the generic hidinput handling */
193 return 0;
194 }
195 }
196
197 /* we have handled the hidinput part, now remains hiddev */
198 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
199 hid->hiddev_hid_event(hid, field, usage, value);
200
201 return 1;
202}
203
204static int egalax_probe(struct hid_device *hdev, const struct hid_device_id *id)
205{
206 int ret;
207 struct egalax_data *td;
208 struct hid_report *report;
209
210 td = kmalloc(sizeof(struct egalax_data), GFP_KERNEL);
211 if (!td) {
212 dev_err(&hdev->dev, "cannot allocate eGalax data\n");
213 return -ENOMEM;
214 }
215 hid_set_drvdata(hdev, td);
216
217 ret = hid_parse(hdev);
218 if (ret)
219 goto end;
220
221 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
222 if (ret)
223 goto end;
224
225 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[5];
226 if (report) {
227 report->field[0]->value[0] = 2;
228 usbhid_submit_report(hdev, report, USB_DIR_OUT);
229 }
230
231end:
232 if (ret)
233 kfree(td);
234
235 return ret;
236}
237
238static void egalax_remove(struct hid_device *hdev)
239{
240 hid_hw_stop(hdev);
241 kfree(hid_get_drvdata(hdev));
242 hid_set_drvdata(hdev, NULL);
243}
244
245static const struct hid_device_id egalax_devices[] = {
246 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
247 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
248 { }
249};
250MODULE_DEVICE_TABLE(hid, egalax_devices);
251
252static const struct hid_usage_id egalax_grabbed_usages[] = {
253 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
254 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
255};
256
257static struct hid_driver egalax_driver = {
258 .name = "egalax-touch",
259 .id_table = egalax_devices,
260 .probe = egalax_probe,
261 .remove = egalax_remove,
262 .input_mapping = egalax_input_mapping,
263 .input_mapped = egalax_input_mapped,
264 .usage_table = egalax_grabbed_usages,
265 .event = egalax_event,
266};
267
268static int __init egalax_init(void)
269{
270 return hid_register_driver(&egalax_driver);
271}
272
273static void __exit egalax_exit(void)
274{
275 hid_unregister_driver(&egalax_driver);
276}
277
278module_init(egalax_init);
279module_exit(egalax_exit);
280
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 797e06470356..413b16527f16 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -170,6 +170,9 @@
170 170
171#define USB_VENDOR_ID_DRAGONRISE 0x0079 171#define USB_VENDOR_ID_DRAGONRISE 0x0079
172 172
173#define USB_VENDOR_ID_DWAV 0x0eef
174#define USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH 0x480d
175
173#define USB_VENDOR_ID_ELO 0x04E7 176#define USB_VENDOR_ID_ELO 0x04E7
174#define USB_DEVICE_ID_ELO_TS2700 0x0020 177#define USB_DEVICE_ID_ELO_TS2700 0x0020
175 178