aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>2011-11-29 07:13:10 -0500
committerJiri Kosina <jkosina@suse.cz>2011-11-30 09:32:18 -0500
commit5e7ea11f603a0aeb77fd1bff0b242931ffe139de (patch)
tree212542059adf62ba0a9ebe2570de63021642cf64
parent1b723e8dc81b23141bfb8991e002073b17fd0199 (diff)
HID: multitouch: merge quanta driver into hid-multitouch
This patch merge the last old-style hid multitouch driver to the generic one. It also adds 2 more quanta pids. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com> Acked-by: Henrik Rydberg <rydberg@euromail.se> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/Kconfig7
-rw-r--r--drivers/hid/Makefile1
-rw-r--r--drivers/hid/hid-ids.h4
-rw-r--r--drivers/hid/hid-multitouch.c23
-rw-r--r--drivers/hid/hid-quanta.c261
5 files changed, 23 insertions, 273 deletions
diff --git a/drivers/hid/Kconfig b/drivers/hid/Kconfig
index 22a4a051f221..ee14f78139f0 100644
--- a/drivers/hid/Kconfig
+++ b/drivers/hid/Kconfig
@@ -350,6 +350,7 @@ config HID_MULTITOUCH
350 - MosArt dual-touch panels 350 - MosArt dual-touch panels
351 - PenMount dual touch panels 351 - PenMount dual touch panels
352 - Pixcir dual touch panels 352 - Pixcir dual touch panels
353 - Quanta panels
353 - eGalax dual-touch panels, including the Joojoo and Wetab tablets 354 - eGalax dual-touch panels, including the Joojoo and Wetab tablets
354 - Stantum multitouch panels 355 - Stantum multitouch panels
355 - Touch International Panels 356 - Touch International Panels
@@ -466,12 +467,6 @@ config HID_PRIMAX
466 Support for Primax devices that are not fully compliant with the 467 Support for Primax devices that are not fully compliant with the
467 HID standard. 468 HID standard.
468 469
469config HID_QUANTA
470 tristate "Quanta Optical Touch panels"
471 depends on USB_HID
472 ---help---
473 Support for Quanta Optical Touch dual-touch panels.
474
475config HID_ROCCAT 470config HID_ROCCAT
476 tristate "Roccat special event support" 471 tristate "Roccat special event support"
477 depends on USB_HID 472 depends on USB_HID
diff --git a/drivers/hid/Makefile b/drivers/hid/Makefile
index 1e0d2a638b28..032d59d70127 100644
--- a/drivers/hid/Makefile
+++ b/drivers/hid/Makefile
@@ -51,7 +51,6 @@ obj-$(CONFIG_HID_MULTITOUCH) += hid-multitouch.o
51obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o 51obj-$(CONFIG_HID_NTRIG) += hid-ntrig.o
52obj-$(CONFIG_HID_ORTEK) += hid-ortek.o 52obj-$(CONFIG_HID_ORTEK) += hid-ortek.o
53obj-$(CONFIG_HID_PRODIKEYS) += hid-prodikeys.o 53obj-$(CONFIG_HID_PRODIKEYS) += hid-prodikeys.o
54obj-$(CONFIG_HID_QUANTA) += hid-quanta.o
55obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o 54obj-$(CONFIG_HID_PANTHERLORD) += hid-pl.o
56obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o 55obj-$(CONFIG_HID_PETALYNX) += hid-petalynx.o
57obj-$(CONFIG_HID_PICOLCD) += hid-picolcd.o 56obj-$(CONFIG_HID_PICOLCD) += hid-picolcd.o
diff --git a/drivers/hid/hid-ids.h b/drivers/hid/hid-ids.h
index 3f5e7d6796b3..afa1d87c9ab2 100644
--- a/drivers/hid/hid-ids.h
+++ b/drivers/hid/hid-ids.h
@@ -584,7 +584,9 @@
584#define USB_DEVICE_ID_PRODIGE_CORDLESS 0x3062 584#define USB_DEVICE_ID_PRODIGE_CORDLESS 0x3062
585 585
586#define USB_VENDOR_ID_QUANTA 0x0408 586#define USB_VENDOR_ID_QUANTA 0x0408
587#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH 0x3000 587#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH 0x3000
588#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001 0x3001
589#define USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008 0x3008
588#define USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN 0x3001 590#define USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN 0x3001
589 591
590#define USB_VENDOR_ID_ROCCAT 0x1e7d 592#define USB_VENDOR_ID_ROCCAT 0x1e7d
diff --git a/drivers/hid/hid-multitouch.c b/drivers/hid/hid-multitouch.c
index 26e9706eedf5..3540d32b2b73 100644
--- a/drivers/hid/hid-multitouch.c
+++ b/drivers/hid/hid-multitouch.c
@@ -88,10 +88,11 @@ struct mt_device {
88 88
89#define MT_CLS_SERIAL 0x0002 89#define MT_CLS_SERIAL 0x0002
90#define MT_CLS_CONFIDENCE 0x0003 90#define MT_CLS_CONFIDENCE 0x0003
91#define MT_CLS_CONFIDENCE_MINUS_ONE 0x0004 91#define MT_CLS_CONFIDENCE_CONTACT_ID 0x0004
92#define MT_CLS_DUAL_INRANGE_CONTACTID 0x0005 92#define MT_CLS_CONFIDENCE_MINUS_ONE 0x0005
93#define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0006 93#define MT_CLS_DUAL_INRANGE_CONTACTID 0x0006
94#define MT_CLS_DUAL_NSMU_CONTACTID 0x0007 94#define MT_CLS_DUAL_INRANGE_CONTACTNUMBER 0x0007
95#define MT_CLS_DUAL_NSMU_CONTACTID 0x0008
95 96
96/* vendor specific classes */ 97/* vendor specific classes */
97#define MT_CLS_3M 0x0101 98#define MT_CLS_3M 0x0101
@@ -140,6 +141,9 @@ struct mt_class mt_classes[] = {
140 .quirks = MT_QUIRK_ALWAYS_VALID}, 141 .quirks = MT_QUIRK_ALWAYS_VALID},
141 { .name = MT_CLS_CONFIDENCE, 142 { .name = MT_CLS_CONFIDENCE,
142 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE }, 143 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE },
144 { .name = MT_CLS_CONFIDENCE_CONTACT_ID,
145 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
146 MT_QUIRK_SLOT_IS_CONTACTID },
143 { .name = MT_CLS_CONFIDENCE_MINUS_ONE, 147 { .name = MT_CLS_CONFIDENCE_MINUS_ONE,
144 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE | 148 .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
145 MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE }, 149 MT_QUIRK_SLOT_IS_CONTACTID_MINUS_ONE },
@@ -783,6 +787,17 @@ static const struct hid_device_id mt_devices[] = {
783 HID_USB_DEVICE(USB_VENDOR_ID_CANDO, 787 HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
784 USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) }, 788 USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },
785 789
790 /* Quanta-based panels */
791 { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
792 HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
793 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
794 { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
795 HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
796 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3001) },
797 { .driver_data = MT_CLS_CONFIDENCE_CONTACT_ID,
798 HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
799 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH_3008) },
800
786 /* Stantum panels */ 801 /* Stantum panels */
787 { .driver_data = MT_CLS_CONFIDENCE, 802 { .driver_data = MT_CLS_CONFIDENCE,
788 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM, 803 HID_USB_DEVICE(USB_VENDOR_ID_STANTUM,
diff --git a/drivers/hid/hid-quanta.c b/drivers/hid/hid-quanta.c
deleted file mode 100644
index 87a54df4d4ac..000000000000
--- a/drivers/hid/hid-quanta.c
+++ /dev/null
@@ -1,261 +0,0 @@
1/*
2 * HID driver for Quanta Optical Touch dual-touch panels
3 *
4 * Copyright (c) 2009-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/slab.h>
19
20MODULE_AUTHOR("Stephane Chatty <chatty@enac.fr>");
21MODULE_DESCRIPTION("Quanta dual-touch panel");
22MODULE_LICENSE("GPL");
23
24#include "hid-ids.h"
25
26struct quanta_data {
27 __u16 x, y;
28 __u8 id;
29 bool valid; /* valid finger data, or just placeholder? */
30 bool first; /* is this the first finger in this frame? */
31 bool activity_now; /* at least one active finger in this frame? */
32 bool activity; /* at least one active finger previously? */
33};
34
35static int quanta_input_mapping(struct hid_device *hdev, struct hid_input *hi,
36 struct hid_field *field, struct hid_usage *usage,
37 unsigned long **bit, int *max)
38{
39 switch (usage->hid & HID_USAGE_PAGE) {
40
41 case HID_UP_GENDESK:
42 switch (usage->hid) {
43 case HID_GD_X:
44 hid_map_usage(hi, usage, bit, max,
45 EV_ABS, ABS_MT_POSITION_X);
46 /* touchscreen emulation */
47 input_set_abs_params(hi->input, ABS_X,
48 field->logical_minimum,
49 field->logical_maximum, 0, 0);
50 return 1;
51 case HID_GD_Y:
52 hid_map_usage(hi, usage, bit, max,
53 EV_ABS, ABS_MT_POSITION_Y);
54 /* touchscreen emulation */
55 input_set_abs_params(hi->input, ABS_Y,
56 field->logical_minimum,
57 field->logical_maximum, 0, 0);
58 return 1;
59 }
60 return 0;
61
62 case HID_UP_DIGITIZER:
63 switch (usage->hid) {
64 case HID_DG_CONFIDENCE:
65 case HID_DG_TIPSWITCH:
66 case HID_DG_INPUTMODE:
67 case HID_DG_DEVICEINDEX:
68 case HID_DG_CONTACTCOUNT:
69 case HID_DG_CONTACTMAX:
70 case HID_DG_TIPPRESSURE:
71 case HID_DG_WIDTH:
72 case HID_DG_HEIGHT:
73 return -1;
74 case HID_DG_INRANGE:
75 /* touchscreen emulation */
76 hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
77 return 1;
78 case HID_DG_CONTACTID:
79 hid_map_usage(hi, usage, bit, max,
80 EV_ABS, ABS_MT_TRACKING_ID);
81 return 1;
82 }
83 return 0;
84
85 case 0xff000000:
86 /* ignore vendor-specific features */
87 return -1;
88 }
89
90 return 0;
91}
92
93static int quanta_input_mapped(struct hid_device *hdev, struct hid_input *hi,
94 struct hid_field *field, struct hid_usage *usage,
95 unsigned long **bit, int *max)
96{
97 if (usage->type == EV_KEY || usage->type == EV_ABS)
98 clear_bit(usage->code, *bit);
99
100 return 0;
101}
102
103/*
104 * this function is called when a whole finger has been parsed,
105 * so that it can decide what to send to the input layer.
106 */
107static void quanta_filter_event(struct quanta_data *td, struct input_dev *input)
108{
109
110 td->first = !td->first; /* touchscreen emulation */
111
112 if (!td->valid) {
113 /*
114 * touchscreen emulation: if no finger in this frame is valid
115 * and there previously was finger activity, this is a release
116 */
117 if (!td->first && !td->activity_now && td->activity) {
118 input_event(input, EV_KEY, BTN_TOUCH, 0);
119 td->activity = false;
120 }
121 return;
122 }
123
124 input_event(input, EV_ABS, ABS_MT_TRACKING_ID, td->id);
125 input_event(input, EV_ABS, ABS_MT_POSITION_X, td->x);
126 input_event(input, EV_ABS, ABS_MT_POSITION_Y, td->y);
127
128 input_mt_sync(input);
129 td->valid = false;
130
131 /* touchscreen emulation: if first active finger in this frame... */
132 if (!td->activity_now) {
133 /* if there was no previous activity, emit touch event */
134 if (!td->activity) {
135 input_event(input, EV_KEY, BTN_TOUCH, 1);
136 td->activity = true;
137 }
138 td->activity_now = true;
139 /* and in any case this is our preferred finger */
140 input_event(input, EV_ABS, ABS_X, td->x);
141 input_event(input, EV_ABS, ABS_Y, td->y);
142 }
143}
144
145
146static int quanta_event(struct hid_device *hid, struct hid_field *field,
147 struct hid_usage *usage, __s32 value)
148{
149 struct quanta_data *td = hid_get_drvdata(hid);
150
151 if (hid->claimed & HID_CLAIMED_INPUT) {
152 struct input_dev *input = field->hidinput->input;
153
154 switch (usage->hid) {
155 case HID_DG_INRANGE:
156 td->valid = !!value;
157 break;
158 case HID_GD_X:
159 td->x = value;
160 break;
161 case HID_GD_Y:
162 td->y = value;
163 quanta_filter_event(td, input);
164 break;
165 case HID_DG_CONTACTID:
166 td->id = value;
167 break;
168 case HID_DG_CONTACTCOUNT:
169 /* touch emulation: this is the last field in a frame */
170 td->first = false;
171 td->activity_now = false;
172 break;
173 case HID_DG_CONFIDENCE:
174 case HID_DG_TIPSWITCH:
175 /* avoid interference from generic hidinput handling */
176 break;
177
178 default:
179 /* fallback to the generic hidinput handling */
180 return 0;
181 }
182 }
183
184 /* we have handled the hidinput part, now remains hiddev */
185 if (hid->claimed & HID_CLAIMED_HIDDEV && hid->hiddev_hid_event)
186 hid->hiddev_hid_event(hid, field, usage, value);
187
188 return 1;
189}
190
191static int quanta_probe(struct hid_device *hdev, const struct hid_device_id *id)
192{
193 int ret;
194 struct quanta_data *td;
195
196 td = kmalloc(sizeof(struct quanta_data), GFP_KERNEL);
197 if (!td) {
198 hid_err(hdev, "cannot allocate Quanta Touch data\n");
199 return -ENOMEM;
200 }
201 td->valid = false;
202 td->activity = false;
203 td->activity_now = false;
204 td->first = false;
205 hid_set_drvdata(hdev, td);
206
207 ret = hid_parse(hdev);
208 if (!ret)
209 ret = hid_hw_start(hdev, HID_CONNECT_DEFAULT);
210
211 if (ret)
212 kfree(td);
213
214 return ret;
215}
216
217static void quanta_remove(struct hid_device *hdev)
218{
219 hid_hw_stop(hdev);
220 kfree(hid_get_drvdata(hdev));
221 hid_set_drvdata(hdev, NULL);
222}
223
224static const struct hid_device_id quanta_devices[] = {
225 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
226 USB_DEVICE_ID_QUANTA_OPTICAL_TOUCH) },
227 { HID_USB_DEVICE(USB_VENDOR_ID_QUANTA,
228 USB_DEVICE_ID_PIXART_IMAGING_INC_OPTICAL_TOUCH_SCREEN) },
229 { }
230};
231MODULE_DEVICE_TABLE(hid, quanta_devices);
232
233static const struct hid_usage_id quanta_grabbed_usages[] = {
234 { HID_ANY_ID, HID_ANY_ID, HID_ANY_ID },
235 { HID_ANY_ID - 1, HID_ANY_ID - 1, HID_ANY_ID - 1}
236};
237
238static struct hid_driver quanta_driver = {
239 .name = "quanta-touch",
240 .id_table = quanta_devices,
241 .probe = quanta_probe,
242 .remove = quanta_remove,
243 .input_mapping = quanta_input_mapping,
244 .input_mapped = quanta_input_mapped,
245 .usage_table = quanta_grabbed_usages,
246 .event = quanta_event,
247};
248
249static int __init quanta_init(void)
250{
251 return hid_register_driver(&quanta_driver);
252}
253
254static void __exit quanta_exit(void)
255{
256 hid_unregister_driver(&quanta_driver);
257}
258
259module_init(quanta_init);
260module_exit(quanta_exit);
261