HID: add autodetection of multitouch devices
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>
Wed, 21 Sep 2011 14:56:54 +0000 (16:56 +0200)
committerJiri Kosina <jkosina@suse.cz>
Mon, 26 Sep 2011 12:18:18 +0000 (14:18 +0200)
As mentioned by http://www.microsoft.com/whdc/device/input/DigitizerDrvs_touch.mspx
multitouch devices are those that have the input report HID_CONTACTID.

This patch detects this and unloads the generic-usb driver.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
drivers/hid/hid-core.c
drivers/hid/hid-input.c
include/linux/hid.h

index 956f84968fa45d258ecbbb9ba0bcde723daa1501..f869ab35e6d6ec89cd822567906fab0ab7a0190d 100644 (file)
@@ -1212,6 +1212,12 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
        if ((connect_mask & HID_CONNECT_HIDINPUT) && !hidinput_connect(hdev,
                                connect_mask & HID_CONNECT_HIDINPUT_FORCE))
                hdev->claimed |= HID_CLAIMED_INPUT;
+       if (hdev->quirks & HID_QUIRK_MULTITOUCH) {
+               /* this device should be handled by hid-multitouch, skip it */
+               hdev->quirks &= ~HID_QUIRK_MULTITOUCH;
+               return -ENODEV;
+       }
+
        if ((connect_mask & HID_CONNECT_HIDDEV) && hdev->hiddev_connect &&
                        !hdev->hiddev_connect(hdev,
                                connect_mask & HID_CONNECT_HIDDEV_FORCE))
index 6559e2e3364ec9cf5a4f56e4f112b47c85a2ce7a..f333139d1a4823b325f4ab6c5063cf926198ce26 100644 (file)
@@ -474,6 +474,10 @@ static void hidinput_configure_usage(struct hid_input *hidinput, struct hid_fiel
                        map_key_clear(BTN_STYLUS2);
                        break;
 
+               case 0x51: /* ContactID */
+                       device->quirks |= HID_QUIRK_MULTITOUCH;
+                       goto unknown;
+
                default:  goto unknown;
                }
                break;
@@ -978,6 +982,13 @@ int hidinput_connect(struct hid_device *hid, unsigned int force)
                }
        }
 
+       if (hid->quirks & HID_QUIRK_MULTITOUCH) {
+               /* generic hid does not know how to handle multitouch devices */
+               if (hidinput)
+                       goto out_cleanup;
+               goto out_unwind;
+       }
+
        if (hidinput && input_register_device(hidinput->input))
                goto out_cleanup;
 
index 9cf8e7ae7450b1fbbb250b664a4d5db8d79c058f..6fb743d72bfefadd675f13d58df7e44c828c9431 100644 (file)
@@ -312,6 +312,7 @@ struct hid_item {
 #define HID_QUIRK_BADPAD                       0x00000020
 #define HID_QUIRK_MULTI_INPUT                  0x00000040
 #define HID_QUIRK_HIDINPUT_FORCE               0x00000080
+#define HID_QUIRK_MULTITOUCH                   0x00000100
 #define HID_QUIRK_SKIP_OUTPUT_REPORTS          0x00010000
 #define HID_QUIRK_FULLSPEED_INTERVAL           0x10000000
 #define HID_QUIRK_NO_INIT_REPORTS              0x20000000