aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hid
diff options
context:
space:
mode:
authorRichard Nauber <richard.nauber@googlemail.com>2011-03-09 00:20:57 -0500
committerJiri Kosina <jkosina@suse.cz>2011-03-14 08:05:08 -0400
commit4875ac114d8bce99838a9b0ee7c3f5469cc6352e (patch)
tree5829b1fd88aa5402366cb1ea1374189d14f7dd24 /drivers/hid
parentf153fc3990d4ad2709a52d7150e2c04363afb1fb (diff)
HID: merge hid-egalax into hid-multitouch
This patch merges the hid-egalax driver into hid-multitouch. There are two types of devices support by the hid-egalax driver: resistive and capacitive. Here, they are implicitly distinguished by the absence of a HID_DG_CONTACTCOUNT field in the latter, so no special code path needs to be introduced. As a side effect, this patch fixes the broken suspend/resume behavior in the old driver. [rydberg@euromail.se: minor fixups] Signed-off-by: Richard Nauber <Richard.Nauber@gmail.com> Signed-off-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers/hid')
-rw-r--r--drivers/hid/Kconfig9
-rw-r--r--drivers/hid/Makefile1
-rw-r--r--drivers/hid/hid-egalax.c279
-rw-r--r--drivers/hid/hid-multitouch.c43
4 files changed, 45 insertions, 287 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index a0b117ddeef5..b4b8b21d437d 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -160,13 +160,6 @@ config HID_EMS_FF
160 Currently the following devices are known to be supported: 160 Currently the following devices are known to be supported:
161 - Trio Linker Plus II 161 - Trio Linker Plus II
162 162
163config HID_EGALAX
164 tristate "eGalax multi-touch panel"
165 depends on USB_HID
166 ---help---
167 Support for the eGalax dual-touch panels, including the
168 Joojoo and Wetab tablets.
169
170config HID_ELECOM 163config HID_ELECOM
171 tristate "ELECOM BM084 bluetooth mouse" 164 tristate "ELECOM BM084 bluetooth mouse"
172 depends on BT_HIDP 165 depends on BT_HIDP
@@ -307,6 +300,8 @@ config HID_MULTITOUCH
307 - IrTouch Infrared USB panels 300 - IrTouch Infrared USB panels
308 - Pixcir dual touch panels 301 - Pixcir dual touch panels
309 - 'Sensing Win7-TwoFinger' panel by GeneralTouch 302 - 'Sensing Win7-TwoFinger' panel by GeneralTouch
303 - eGalax dual-touch panels, including the
304 Joojoo and Wetab tablets
310 305
311 If unsure, say N. 306 If unsure, say N.
312 307
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 6efc2a0370ad..29e98985b901 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -36,7 +36,6 @@ obj-$(CONFIG_HID_CHICONY) += hid-chicony.o
36obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o 36obj-$(CONFIG_HID_CYPRESS) += hid-cypress.o
37obj-$(CONFIG_HID_DRAGONRISE) += hid-drff.o 37obj-$(CONFIG_HID_DRAGONRISE) += hid-drff.o
38obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o 38obj-$(CONFIG_HID_EMS_FF) += hid-emsff.o
39obj-$(CONFIG_HID_EGALAX) += hid-egalax.o
40obj-$(CONFIG_HID_ELECOM) += hid-elecom.o 39obj-$(CONFIG_HID_ELECOM) += hid-elecom.o
41obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o 40obj-$(CONFIG_HID_EZKEY) += hid-ezkey.o
42obj-$(CONFIG_HID_GYRATION) += hid-gyration.o 41obj-$(CONFIG_HID_GYRATION) += hid-gyration.o
diff --git a/drivers/hid/hid-egalax.c b/drivers/hid/hid-egalax.c
deleted file mode 100644
index 03bee1970d70..000000000000
--- a/drivers/hid/hid-egalax.c
+++ /dev/null
@@ -1,279 +0,0 @@
1/*
2 * HID driver for eGalax dual-touch panels
3 *
4 * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr>
5 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
6 * Copyright (c) 2010 Canonical, Ltd.
7 *
8 */
9
10/*
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the Free
13 * Software Foundation; either version 2 of the License, or (at your option)
14 * any later version.
15 */
16
17#include <linux/device.h>
18#include <linux/hid.h>
19#include <linux/module.h>
20#include <linux/usb.h>
21#include <linux/input/mt.h>
22#include <linux/slab.h>
23#include "usbhid/usbhid.h"
24
25MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
26MODULE_DESCRIPTION("eGalax dual-touch panel");
27MODULE_LICENSE("GPL");
28
29#include "hid-ids.h"
30
31#define MAX_SLOTS 2
32
33/* estimated signal-to-noise ratios */
34#define SN_MOVE 4096
35#define SN_PRESSURE 32
36
37struct egalax_data {
38 int valid;
39 int slot;
40 int touch;
41 int x, y, z;
42};
43
44static void set_abs(struct input_dev *input, unsigned int code,
45 struct hid_field *field, int snratio)
46{
47 int fmin = field->logical_minimum;
48 int fmax = field->logical_maximum;
49 int fuzz = snratio ? (fmax - fmin) / snratio : 0;
50 input_set_abs_params(input, code, fmin, fmax, fuzz, 0);
51}
52
53static int egalax_input_mapping(struct hid_device *hdev, struct hid_input *hi,
54 struct hid_field *field, struct hid_usage *usage,
55 unsigned long **bit, int *max)
56{
57 struct input_dev *input = hi->input;
58
59 switch (usage->hid & HID_USAGE_PAGE) {
60
61 case HID_UP_GENDESK:
62 switch (usage->hid) {
63 case HID_GD_X:
64 field->logical_maximum = 32760;
65 hid_map_usage(hi, usage, bit, max,
66 EV_ABS, ABS_MT_POSITION_X);
67 set_abs(input, ABS_MT_POSITION_X, field, SN_MOVE);
68 /* touchscreen emulation */
69 set_abs(input, ABS_X, field, SN_MOVE);
70 return 1;
71 case HID_GD_Y:
72 field->logical_maximum = 32760;
73 hid_map_usage(hi, usage, bit, max,
74 EV_ABS, ABS_MT_POSITION_Y);
75 set_abs(input, ABS_MT_POSITION_Y, field, SN_MOVE);
76 /* touchscreen emulation */
77 set_abs(input, ABS_Y, field, SN_MOVE);
78 return 1;
79 }
80 return 0;
81
82 case HID_UP_DIGITIZER:
83 switch (usage->hid) {
84 case HID_DG_TIPSWITCH:
85 /* touchscreen emulation */
86 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
87 input_set_capability(input, EV_KEY, BTN_TOUCH);
88 return 1;
89 case HID_DG_INRANGE:
90 case HID_DG_CONFIDENCE:
91 case HID_DG_CONTACTCOUNT:
92 case HID_DG_CONTACTMAX:
93 return -1;
94 case HID_DG_CONTACTID:
95 input_mt_init_slots(input, MAX_SLOTS);
96 return 1;
97 case HID_DG_TIPPRESSURE:
98 field->logical_minimum = 0;
99 hid_map_usage(hi, usage, bit, max,
100 EV_ABS, ABS_MT_PRESSURE);
101 set_abs(input, ABS_MT_PRESSURE, field, SN_PRESSURE);
102 /* touchscreen emulation */
103 set_abs(input, ABS_PRESSURE, field, SN_PRESSURE);
104 return 1;
105 }
106 return 0;
107 }
108
109 /* ignore others (from other reports we won't get anyway) */
110 return -1;
111}
112
113static int egalax_input_mapped(struct hid_device *hdev, struct hid_input *hi,
114 struct hid_field *field, struct hid_usage *usage,
115 unsigned long **bit, int *max)
116{
117 /* tell hid-input to skip setup of these event types */
118 if (usage->type == EV_KEY || usage->type == EV_ABS)
119 set_bit(usage->type, hi->input->evbit);
120 return -1;
121}
122
123/*
124 * this function is called when a whole finger has been parsed,
125 * so that it can decide what to send to the input layer.
126 */
127static void egalax_filter_event(struct egalax_data *td, struct input_dev *input)
128{
129 input_mt_slot(input, td->slot);
130 input_mt_report_slot_state(input, MT_TOOL_FINGER, td->touch);
131 if (td->touch) {
132 input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x);
133 input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y);
134 input_event(input, EV_ABS, ABS_MT_PRESSURE, td->z);
135 }
136 input_mt_report_pointer_emulation(input, true);
137}
138
139static int egalax_event(struct hid_device *hid, struct hid_field *field,
140 struct hid_usage *usage, __s32 value)
141{
142 struct egalax_data *td = hid_get_drvdata(hid);
143
144 /* Note, eGalax has two product lines: the first is resistive and
145 * uses a standard parallel multitouch protocol (product ID ==
146 * 48xx). The second is capacitive and uses an unusual "serial"
147 * protocol with a different message for each multitouch finger
148 * (product ID == 72xx).
149 */
150 if (hid->claimed & HID_CLAIMED_INPUT) {
151 struct input_dev *input = field->hidinput->input;
152
153 switch (usage->hid) {
154 case HID_DG_INRANGE:
155 td->valid = value;
156 break;
157 case HID_DG_CONFIDENCE:
158 /* avoid interference from generic hidinput handling */
159 break;
160 case HID_DG_TIPSWITCH:
161 td->touch = value;
162 break;
163 case HID_DG_TIPPRESSURE:
164 td->z = value;
165 break;
166 case HID_DG_CONTACTID:
167 td->slot = clamp_val(value, 0, MAX_SLOTS - 1);
168 break;
169 case HID_GD_X:
170 td->x = value;
171 break;
172 case HID_GD_Y:
173 td->y = value;
174 /* this is the last field in a finger */
175 if (td->valid)
176 egalax_filter_event(td, input);
177 break;
178 case HID_DG_CONTACTCOUNT:
179 /* touch emulation: this is the last field in a frame */
180 break;
181
182 default:
183 /* fallback to the generic hidinput handling */
184 return 0;
185 }
186 }
187
188 /* we have handled the hidinput part, now remains hiddev */
189 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
190 hid->hiddev_hid_event(hid, field, usage, value);
191
192 return 1;
193}
194
195static int egalax_probe(struct hid_device *hdev, const struct hid_device_id *id)
196{
197 int ret;
198 struct egalax_data *td;
199 struct hid_report *report;
200
201 td = kzalloc(sizeof(struct egalax_data), GFP_KERNEL);
202 if (!td) {
203 hid_err(hdev, "cannot allocate eGalax data\n");
204 return -ENOMEM;
205 }
206 hid_set_drvdata(hdev, td);
207
208 ret = hid_parse(hdev);
209 if (ret)
210 goto end;
211
212 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
213 if (ret)
214 goto end;
215
216 report = hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[5];
217 if (report) {
218 report->field[0]->value[0] = 2;
219 usbhid_submit_report(hdev, report, USB_DIR_OUT);
220 }
221
222end:
223 if (ret)
224 kfree(td);
225
226 return ret;
227}
228
229static void egalax_remove(struct hid_device *hdev)
230{
231 hid_hw_stop(hdev);
232 kfree(hid_get_drvdata(hdev));
233 hid_set_drvdata(hdev, NULL);
234}
235
236static const struct hid_device_id egalax_devices[] = {
237 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
238 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
239 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
240 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) },
241 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
242 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) },
243 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
244 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) },
245 { HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
246 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) },
247 { }
248};
249MODULE_DEVICE_TABLE(hid, egalax_devices);
250
251static const struct hid_usage_id egalax_grabbed_usages[] = {
252 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
253 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
254};
255
256static struct hid_driver egalax_driver = {
257 .name = "egalax-touch",
258 .id_table = egalax_devices,
259 .probe = egalax_probe,
260 .remove = egalax_remove,
261 .input_mapping = egalax_input_mapping,
262 .input_mapped = egalax_input_mapped,
263 .usage_table = egalax_grabbed_usages,
264 .event = egalax_event,
265};
266
267static int __init egalax_init(void)
268{
269 return hid_register_driver(&egalax_driver);
270}
271
272static void __exit egalax_exit(void)
273{
274 hid_unregister_driver(&egalax_driver);
275}
276
277module_init(egalax_init);
278module_exit(egalax_exit);
279
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 4518006f4871..af5a7093b204 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -5,6 +5,12 @@
5 * Copyright (c) 2010-2011 Benjamin Tissoires <benjamin.tissoires@gmail.com> 5 * Copyright (c) 2010-2011 Benjamin Tissoires <benjamin.tissoires@gmail.com>
6 * Copyright (c) 2010-2011 Ecole Nationale de l'Aviation Civile, France 6 * Copyright (c) 2010-2011 Ecole Nationale de l'Aviation Civile, France
7 * 7 *
8 * This code is partly based on hid-egalax.c:
9 *
10 * Copyright (c) 2010 Stephane Chatty <chatty@enac.fr>
11 * Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
12 * Copyright (c) 2010 Canonical, Ltd.
13 *
8 */ 14 */
9 15
10/* 16/*
@@ -37,6 +43,7 @@ MODULE_LICENSE("GPL");
37#define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3) 43#define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3)
38#define MT_QUIRK_VALID_IS_INRANGE (1 << 4) 44#define MT_QUIRK_VALID_IS_INRANGE (1 << 4)
39#define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 5) 45#define MT_QUIRK_VALID_IS_CONFIDENCE (1 << 5)
46#define MT_QUIRK_EGALAX_XYZ_FIXUP (1 << 6)
40 47
41struct mt_slot { 48struct mt_slot {
42 __s32 x, y, p, w, h; 49 __s32 x, y, p, w, h;
@@ -70,6 +77,7 @@ struct mt_class {
70#define MT_CLS_DUAL_INRANGE_CONTACTID 2 77#define MT_CLS_DUAL_INRANGE_CONTACTID 2
71#define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 3 78#define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 3
72#define MT_CLS_CYPRESS 4 79#define MT_CLS_CYPRESS 4
80#define MT_CLS_EGALAX 5
73 81
74/* 82/*
75 * these device-dependent functions determine what slot corresponds 83 * these device-dependent functions determine what slot corresponds
@@ -120,6 +128,14 @@ struct mt_class mt_classes[] = {
120 MT_QUIRK_CYPRESS, 128 MT_QUIRK_CYPRESS,
121 .maxcontacts = 10 }, 129 .maxcontacts = 10 },
122 130
131 { .name = MT_CLS_EGALAX,
132 .quirks = MT_QUIRK_SLOT_IS_CONTACTID |
133 MT_QUIRK_VALID_IS_INRANGE |
134 MT_QUIRK_EGALAX_XYZ_FIXUP,
135 .maxcontacts = 2,
136 .sn_move = 4096,
137 .sn_pressure = 32,
138 },
123 { } 139 { }
124}; 140};
125 141
@@ -147,11 +163,15 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
147{ 163{
148 struct mt_device *td = hid_get_drvdata(hdev); 164 struct mt_device *td = hid_get_drvdata(hdev);
149 struct mt_class *cls = td->mtclass; 165 struct mt_class *cls = td->mtclass;
166 __s32 quirks = cls->quirks;
167
150 switch (usage->hid & HID_USAGE_PAGE) { 168 switch (usage->hid & HID_USAGE_PAGE) {
151 169
152 case HID_UP_GENDESK: 170 case HID_UP_GENDESK:
153 switch (usage->hid) { 171 switch (usage->hid) {
154 case HID_GD_X: 172 case HID_GD_X:
173 if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
174 field->logical_maximum = 32760;
155 hid_map_usage(hi, usage, bit, max, 175 hid_map_usage(hi, usage, bit, max,
156 EV_ABS, ABS_MT_POSITION_X); 176 EV_ABS, ABS_MT_POSITION_X);
157 set_abs(hi->input, ABS_MT_POSITION_X, field, 177 set_abs(hi->input, ABS_MT_POSITION_X, field,
@@ -161,6 +181,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
161 td->last_slot_field = usage->hid; 181 td->last_slot_field = usage->hid;
162 return 1; 182 return 1;
163 case HID_GD_Y: 183 case HID_GD_Y:
184 if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
185 field->logical_maximum = 32760;
164 hid_map_usage(hi, usage, bit, max, 186 hid_map_usage(hi, usage, bit, max,
165 EV_ABS, ABS_MT_POSITION_Y); 187 EV_ABS, ABS_MT_POSITION_Y);
166 set_abs(hi->input, ABS_MT_POSITION_Y, field, 188 set_abs(hi->input, ABS_MT_POSITION_Y, field,
@@ -204,6 +226,8 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
204 td->last_slot_field = usage->hid; 226 td->last_slot_field = usage->hid;
205 return 1; 227 return 1;
206 case HID_DG_TIPPRESSURE: 228 case HID_DG_TIPPRESSURE:
229 if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
230 field->logical_minimum = 0;
207 hid_map_usage(hi, usage, bit, max, 231 hid_map_usage(hi, usage, bit, max,
208 EV_ABS, ABS_MT_PRESSURE); 232 EV_ABS, ABS_MT_PRESSURE);
209 set_abs(hi->input, ABS_MT_PRESSURE, field, 233 set_abs(hi->input, ABS_MT_PRESSURE, field,
@@ -487,6 +511,25 @@ static const struct hid_device_id mt_devices[] = {
487 HID_USB_DEVICE(USB_VENDOR_ID_CANDO, 511 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
488 USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, 512 USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },
489 513
514 /* Resistive eGalax devices */
515 { .driver_data = MT_CLS_EGALAX,
516 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
517 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
518 { .driver_data = MT_CLS_EGALAX,
519 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
520 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) },
521
522 /* Capacitive eGalax devices */
523 { .driver_data = MT_CLS_EGALAX,
524 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
525 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) },
526 { .driver_data = MT_CLS_EGALAX,
527 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
528 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) },
529 { .driver_data = MT_CLS_EGALAX,
530 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
531 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) },
532
490 { } 533 { }
491}; 534};
492MODULE_DEVICE_TABLE(hid, mt_devices); 535MODULE_DEVICE_TABLE(hid, mt_devices);