OSDN Git Service

HID: merge hid-egalax into hid-multitouch
authorRichard Nauber <richard.nauber@googlemail.com>
Wed, 9 Mar 2011 05:20:57 +0000 (06:20 +0100)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 6 Apr 2011 03:11:51 +0000 (11:11 +0800)
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>
drivers/hid/Kconfig
drivers/hid/Makefile
drivers/hid/hid-multitouch.c

index 4a787c6..d00232d 100644 (file)
@@ -160,13 +160,6 @@ config HID_EMS_FF
        Currently the following devices are known to be supported:
         - Trio Linker Plus II
 
-config HID_EGALAX
-       tristate "eGalax multi-touch panel"
-       depends on USB_HID
-       ---help---
-       Support for the eGalax dual-touch panels, including the
-       Joojoo and Wetab tablets.
-
 config HID_ELECOM
        tristate "ELECOM BM084 bluetooth mouse"
        depends on BT_HIDP
@@ -307,6 +300,8 @@ config HID_MULTITOUCH
          - IrTouch Infrared USB panels
          - Pixcir dual touch panels
          - 'Sensing Win7-TwoFinger' panel by GeneralTouch
+          - eGalax dual-touch panels, including the
+           Joojoo and Wetab tablets
 
          If unsure, say N.
 
index 6efc2a0..29e9898 100644 (file)
@@ -36,7 +36,6 @@ obj-$(CONFIG_HID_CHICONY)     += hid-chicony.o
 obj-$(CONFIG_HID_CYPRESS)      += hid-cypress.o
 obj-$(CONFIG_HID_DRAGONRISE)   += hid-drff.o
 obj-$(CONFIG_HID_EMS_FF)       += hid-emsff.o
-obj-$(CONFIG_HID_EGALAX)       += hid-egalax.o
 obj-$(CONFIG_HID_ELECOM)       += hid-elecom.o
 obj-$(CONFIG_HID_EZKEY)                += hid-ezkey.o
 obj-$(CONFIG_HID_GYRATION)     += hid-gyration.o
index 4518006..af5a709 100644 (file)
@@ -5,6 +5,12 @@
  *  Copyright (c) 2010-2011 Benjamin Tissoires <benjamin.tissoires@gmail.com>
  *  Copyright (c) 2010-2011 Ecole Nationale de l'Aviation Civile, France
  *
+ *  This code is partly based on hid-egalax.c:
+ *
+ *  Copyright (c) 2010 Stephane Chatty <chatty@enac.fr>
+ *  Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
+ *  Copyright (c) 2010 Canonical, Ltd.
+ *
  */
 
 /*
@@ -37,6 +43,7 @@ MODULE_LICENSE("GPL");
 #define MT_QUIRK_SLOT_IS_CONTACTNUMBER (1 << 3)
 #define MT_QUIRK_VALID_IS_INRANGE      (1 << 4)
 #define MT_QUIRK_VALID_IS_CONFIDENCE   (1 << 5)
+#define MT_QUIRK_EGALAX_XYZ_FIXUP      (1 << 6)
 
 struct mt_slot {
        __s32 x, y, p, w, h;
@@ -70,6 +77,7 @@ struct mt_class {
 #define MT_CLS_DUAL_INRANGE_CONTACTID          2
 #define MT_CLS_DUAL_INRANGE_CONTACTNUMBER      3
 #define MT_CLS_CYPRESS                         4
+#define MT_CLS_EGALAX                          5
 
 /*
  * these device-dependent functions determine what slot corresponds
@@ -120,6 +128,14 @@ struct mt_class mt_classes[] = {
                        MT_QUIRK_CYPRESS,
                .maxcontacts = 10 },
 
+       { .name = MT_CLS_EGALAX,
+               .quirks =  MT_QUIRK_SLOT_IS_CONTACTID |
+                       MT_QUIRK_VALID_IS_INRANGE |
+                       MT_QUIRK_EGALAX_XYZ_FIXUP,
+               .maxcontacts = 2,
+               .sn_move = 4096,
+               .sn_pressure = 32,
+       },
        { }
 };
 
@@ -147,11 +163,15 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
 {
        struct mt_device *td = hid_get_drvdata(hdev);
        struct mt_class *cls = td->mtclass;
+       __s32 quirks = cls->quirks;
+
        switch (usage->hid & HID_USAGE_PAGE) {
 
        case HID_UP_GENDESK:
                switch (usage->hid) {
                case HID_GD_X:
+                       if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
+                               field->logical_maximum = 32760;
                        hid_map_usage(hi, usage, bit, max,
                                        EV_ABS, ABS_MT_POSITION_X);
                        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,
                        td->last_slot_field = usage->hid;
                        return 1;
                case HID_GD_Y:
+                       if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
+                               field->logical_maximum = 32760;
                        hid_map_usage(hi, usage, bit, max,
                                        EV_ABS, ABS_MT_POSITION_Y);
                        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,
                        td->last_slot_field = usage->hid;
                        return 1;
                case HID_DG_TIPPRESSURE:
+                       if (quirks & MT_QUIRK_EGALAX_XYZ_FIXUP)
+                               field->logical_minimum = 0;
                        hid_map_usage(hi, usage, bit, max,
                                        EV_ABS, ABS_MT_PRESSURE);
                        set_abs(hi->input, ABS_MT_PRESSURE, field,
@@ -487,6 +511,25 @@ static const struct hid_device_id mt_devices[] = {
                HID_USB_DEVICE(USB_VENDOR_ID_CANDO,
                        USB_DEVICE_ID_CANDO_PIXCIR_MULTI_TOUCH) },
 
+       /* Resistive eGalax devices */
+       {  .driver_data = MT_CLS_EGALAX,
+               HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
+                       USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH) },
+       {  .driver_data = MT_CLS_EGALAX,
+               HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
+                       USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH3) },
+
+       /* Capacitive eGalax devices */
+       {  .driver_data = MT_CLS_EGALAX,
+               HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
+                       USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH1) },
+       {  .driver_data = MT_CLS_EGALAX,
+               HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
+                       USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH2) },
+       {  .driver_data = MT_CLS_EGALAX,
+               HID_USB_DEVICE(USB_VENDOR_ID_DWAV,
+                       USB_DEVICE_ID_DWAV_EGALAX_MULTITOUCH4) },
+
        { }
 };
 MODULE_DEVICE_TABLE(hid, mt_devices);