aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@enac.fr>2011-03-18 09:27:53 -0400
committerJiri Kosina <jkosina@suse.cz>2011-03-21 12:05:02 -0400
commit043b403aede4a528ed99ceaf050f567f1283a23e (patch)
treec3d67092fcba29716fdd7481968d8f9449127f35 /drivers
parent9498f954a4ec389806333041a1018909c6fe0518 (diff)
HID: hid-multitouch: migrate support for Stantum panels to the unified driver.
This patch merges hid-stantum to the generic multitouch driver. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr> Reviewed-by: Stéphane Chatty <chatty@enac.fr> Reviewed-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/Kconfig7
-rw-r--r--drivers/hid/Makefile1
-rw-r--r--drivers/hid/hid-multitouch.c15
-rw-r--r--drivers/hid/hid-stantum.c286
4 files changed, 16 insertions, 293 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index b7ec4057841d..3c72f16e725f 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -327,6 +327,7 @@ config HID_MULTITOUCH
327 - 'Sensing Win7-TwoFinger' panel by GeneralTouch 327 - 'Sensing Win7-TwoFinger' panel by GeneralTouch
328 - eGalax dual-touch panels, including the 328 - eGalax dual-touch panels, including the
329 Joojoo and Wetab tablets 329 Joojoo and Wetab tablets
330 - Stantum multitouch panels
330 331
331 If unsure, say N. 332 If unsure, say N.
332 333
@@ -493,12 +494,6 @@ config HID_SONY
493 ---help--- 494 ---help---
494 Support for Sony PS3 controller. 495 Support for Sony PS3 controller.
495 496
496config HID_STANTUM
497 tristate "Stantum multitouch panel"
498 depends on USB_HID
499 ---help---
500 Support for Stantum multitouch panel.
501
502config HID_SUNPLUS 497config HID_SUNPLUS
503 tristate "Sunplus wireless desktop" 498 tristate "Sunplus wireless desktop"
504 depends on USB_HID 499 depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 06c68ae3abee..a13cb4e99fff 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -66,7 +66,6 @@ obj-$(CONFIG_HID_ROCCAT_PYRA) += hid-roccat-pyra.o
66obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o 66obj-$(CONFIG_HID_SAMSUNG) += hid-samsung.o
67obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o 67obj-$(CONFIG_HID_SMARTJOYPLUS) += hid-sjoy.o
68obj-$(CONFIG_HID_SONY) += hid-sony.o 68obj-$(CONFIG_HID_SONY) += hid-sony.o
69obj-$(CONFIG_HID_STANTUM) += hid-stantum.o
70obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o 69obj-$(CONFIG_HID_SUNPLUS) += hid-sunplus.o
71obj-$(CONFIG_HID_GREENASIA) += hid-gaff.o 70obj-$(CONFIG_HID_GREENASIA) += hid-gaff.o
72obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o 71obj-$(CONFIG_HID_THRUSTMASTER) += hid-tmff.o
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index b9f9eeceaa98..5983e5559e81 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -79,6 +79,7 @@ struct mt_class {
79#define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 3 79#define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 3
80#define MT_CLS_CYPRESS 4 80#define MT_CLS_CYPRESS 4
81#define MT_CLS_EGALAX 5 81#define MT_CLS_EGALAX 5
82#define MT_CLS_STANTUM 6
82 83
83#define MT_DEFAULT_MAXCONTACT 10 84#define MT_DEFAULT_MAXCONTACT 10
84 85
@@ -138,6 +139,9 @@ struct mt_class mt_classes[] = {
138 .sn_move = 4096, 139 .sn_move = 4096,
139 .sn_pressure = 32, 140 .sn_pressure = 32,
140 }, 141 },
142 { .name = MT_CLS_STANTUM,
143 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE },
144
141 { } 145 { }
142}; 146};
143 147
@@ -552,6 +556,17 @@ static const struct hid_device_id mt_devices[] = {
552 HID_USB_DEVICE(USB_VENDOR_ID_DWAV, 556 HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
553 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) }, 557 USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) },
554 558
559 /* Stantum panels */
560 { .driver_data = MT_CLS_STANTUM,
561 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
562 USB_DEVICE_ID_MTP)},
563 { .driver_data = MT_CLS_STANTUM,
564 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
565 USB_DEVICE_ID_MTP_STM)},
566 { .driver_data = MT_CLS_STANTUM,
567 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
568 USB_DEVICE_ID_MTP_SITRONIX)},
569
555 { } 570 { }
556}; 571};
557MODULE_DEVICE_TABLE(hid, mt_devices); 572MODULE_DEVICE_TABLE(hid, mt_devices);
diff --git a/drivers/hid/hid-stantum.c b/drivers/hid/hid-stantum.c
deleted file mode 100644
index b2be1d11916b..000000000000
--- a/drivers/hid/hid-stantum.c
+++ /dev/null
@@ -1,286 +0,0 @@
1/*
2 * HID driver for Stantum multitouch panels
3 *
4 * Copyright (c) 2009 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/slab.h>
19
20MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
21MODULE_DESCRIPTION("Stantum HID multitouch panels");
22MODULE_LICENSE("GPL");
23
24#include "hid-ids.h"
25
26struct stantum_data {
27 __s32 x, y, z, w, h; /* x, y, pressure, width, height */
28 __u16 id; /* touch id */
29 bool valid; /* valid finger data, or just placeholder? */
30 bool first; /* first finger in the HID packet? */
31 bool activity; /* at least one active finger so far? */
32};
33
34static int stantum_input_mapping(struct hid_device *hdev, struct hid_input *hi,
35 struct hid_field *field, struct hid_usage *usage,
36 unsigned long **bit, int *max)
37{
38 switch (usage->hid & HID_USAGE_PAGE) {
39
40 case HID_UP_GENDESK:
41 switch (usage->hid) {
42 case HID_GD_X:
43 hid_map_usage(hi, usage, bit, max,
44 EV_ABS, ABS_MT_POSITION_X);
45 /* touchscreen emulation */
46 input_set_abs_params(hi->input, ABS_X,
47 field->logical_minimum,
48 field->logical_maximum, 0, 0);
49 return 1;
50 case HID_GD_Y:
51 hid_map_usage(hi, usage, bit, max,
52 EV_ABS, ABS_MT_POSITION_Y);
53 /* touchscreen emulation */
54 input_set_abs_params(hi->input, ABS_Y,
55 field->logical_minimum,
56 field->logical_maximum, 0, 0);
57 return 1;
58 }
59 return 0;
60
61 case HID_UP_DIGITIZER:
62 switch (usage->hid) {
63 case HID_DG_INRANGE:
64 case HID_DG_CONFIDENCE:
65 case HID_DG_INPUTMODE:
66 case HID_DG_DEVICEINDEX:
67 case HID_DG_CONTACTCOUNT:
68 case HID_DG_CONTACTMAX:
69 return -1;
70
71 case HID_DG_TIPSWITCH:
72 /* touchscreen emulation */
73 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
74 return 1;
75
76 case HID_DG_WIDTH:
77 hid_map_usage(hi, usage, bit, max,
78 EV_ABS, ABS_MT_TOUCH_MAJOR);
79 return 1;
80 case HID_DG_HEIGHT:
81 hid_map_usage(hi, usage, bit, max,
82 EV_ABS, ABS_MT_TOUCH_MINOR);
83 input_set_abs_params(hi->input, ABS_MT_ORIENTATION,
84 1, 1, 0, 0);
85 return 1;
86 case HID_DG_TIPPRESSURE:
87 hid_map_usage(hi, usage, bit, max,
88 EV_ABS, ABS_MT_PRESSURE);
89 return 1;
90
91 case HID_DG_CONTACTID:
92 hid_map_usage(hi, usage, bit, max,
93 EV_ABS, ABS_MT_TRACKING_ID);
94 return 1;
95
96 }
97 return 0;
98
99 case 0xff000000:
100 /* no input-oriented meaning */
101 return -1;
102 }
103
104 return 0;
105}
106
107static int stantum_input_mapped(struct hid_device *hdev, struct hid_input *hi,
108 struct hid_field *field, struct hid_usage *usage,
109 unsigned long **bit, int *max)
110{
111 if (usage->type == EV_KEY || usage->type == EV_ABS)
112 clear_bit(usage->code, *bit);
113
114 return 0;
115}
116
117/*
118 * this function is called when a whole finger has been parsed,
119 * so that it can decide what to send to the input layer.
120 */
121static void stantum_filter_event(struct stantum_data *sd,
122 struct input_dev *input)
123{
124 bool wide;
125
126 if (!sd->valid) {
127 /*
128 * touchscreen emulation: if the first finger is not valid and
129 * there previously was finger activity, this is a release
130 */
131 if (sd->first && sd->activity) {
132 input_event(input, EV_KEY, BTN_TOUCH, 0);
133 sd->activity = false;
134 }
135 return;
136 }
137
138 input_event(input, EV_ABS, ABS_MT_TRACKING_ID, sd->id);
139 input_event(input, EV_ABS, ABS_MT_POSITION_X, sd->x);
140 input_event(input, EV_ABS, ABS_MT_POSITION_Y, sd->y);
141
142 wide = (sd->w > sd->h);
143 input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
144 input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, wide ? sd->w : sd->h);
145 input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, wide ? sd->h : sd->w);
146
147 input_event(input, EV_ABS, ABS_MT_PRESSURE, sd->z);
148
149 input_mt_sync(input);
150 sd->valid = false;
151
152 /* touchscreen emulation */
153 if (sd->first) {
154 if (!sd->activity) {
155 input_event(input, EV_KEY, BTN_TOUCH, 1);
156 sd->activity = true;
157 }
158 input_event(input, EV_ABS, ABS_X, sd->x);
159 input_event(input, EV_ABS, ABS_Y, sd->y);
160 }
161 sd->first = false;
162}
163
164
165static int stantum_event(struct hid_device *hid, struct hid_field *field,
166 struct hid_usage *usage, __s32 value)
167{
168 struct stantum_data *sd = hid_get_drvdata(hid);
169
170 if (hid->claimed & HID_CLAIMED_INPUT) {
171 struct input_dev *input = field->hidinput->input;
172
173 switch (usage->hid) {
174 case HID_DG_INRANGE:
175 /* this is the last field in a finger */
176 stantum_filter_event(sd, input);
177 break;
178 case HID_DG_WIDTH:
179 sd->w = value;
180 break;
181 case HID_DG_HEIGHT:
182 sd->h = value;
183 break;
184 case HID_GD_X:
185 sd->x = value;
186 break;
187 case HID_GD_Y:
188 sd->y = value;
189 break;
190 case HID_DG_TIPPRESSURE:
191 sd->z = value;
192 break;
193 case HID_DG_CONTACTID:
194 sd->id = value;
195 break;
196 case HID_DG_CONFIDENCE:
197 sd->valid = !!value;
198 break;
199 case 0xff000002:
200 /* this comes only before the first finger */
201 sd->first = true;
202 break;
203
204 default:
205 /* ignore the others */
206 return 1;
207 }
208 }
209
210 /* we have handled the hidinput part, now remains hiddev */
211 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
212 hid->hiddev_hid_event(hid, field, usage, value);
213
214 return 1;
215}
216
217static int stantum_probe(struct hid_device *hdev,
218 const struct hid_device_id *id)
219{
220 int ret;
221 struct stantum_data *sd;
222
223 sd = kmalloc(sizeof(struct stantum_data), GFP_KERNEL);
224 if (!sd) {
225 hid_err(hdev, "cannot allocate Stantum data\n");
226 return -ENOMEM;
227 }
228 sd->valid = false;
229 sd->first = false;
230 sd->activity = false;
231 hid_set_drvdata(hdev, sd);
232
233 ret = hid_parse(hdev);
234 if (!ret)
235 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
236
237 if (ret)
238 kfree(sd);
239
240 return ret;
241}
242
243static void stantum_remove(struct hid_device *hdev)
244{
245 hid_hw_stop(hdev);
246 kfree(hid_get_drvdata(hdev));
247 hid_set_drvdata(hdev, NULL);
248}
249
250static const struct hid_device_id stantum_devices[] = {
251 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, USB_DEVICE_ID_MTP) },
252 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_STM, USB_DEVICE_ID_MTP_STM) },
253 { HID_USB_DEVICE(USB_VENDOR_ID_STANTUM_SITRONIX, USB_DEVICE_ID_MTP_SITRONIX) },
254 { }
255};
256MODULE_DEVICE_TABLE(hid, stantum_devices);
257
258static const struct hid_usage_id stantum_grabbed_usages[] = {
259 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
260 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
261};
262
263static struct hid_driver stantum_driver = {
264 .name = "stantum",
265 .id_table = stantum_devices,
266 .probe = stantum_probe,
267 .remove = stantum_remove,
268 .input_mapping = stantum_input_mapping,
269 .input_mapped = stantum_input_mapped,
270 .usage_table = stantum_grabbed_usages,
271 .event = stantum_event,
272};
273
274static int __init stantum_init(void)
275{
276 return hid_register_driver(&stantum_driver);
277}
278
279static void __exit stantum_exit(void)
280{
281 hid_unregister_driver(&stantum_driver);
282}
283
284module_init(stantum_init);
285module_exit(stantum_exit);
286