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