OSDN Git Service

HID: hid-multitouch: migrate 3M PCT touch screens to hid-multitouch
authorBenjamin Tissoires <benjamin.tissoires@gmail.com>
Mon, 4 Apr 2011 08:47:48 +0000 (10:47 +0200)
committerChih-Wei Huang <cwhuang@linux.org.tw>
Wed, 6 Apr 2011 03:14:02 +0000 (11:14 +0800)
This patch merges the hid-3m-pct driver into hid-multitouch.
To keep devices working the same way they used to with hid-3m-pct,
we need to add two signal/noise ratios for width and height.
We also need to work on width/height to send proper
ABS_MT_ORIENTATION flag.

Importing 3M into hid-multitouch also solved the bug in which
devices handling width and height in their report descriptors
did not show ABS_MT_TOUCH_MAJOR and ABS_MT_TOUCH_MINOR.

Signed-off-by: Benjamin Tissoires <benjamin.tissoires@enac.fr>
Reviewed-by: Stéphane Chatty <chatty@enac.fr>
Reviewed-and-tested-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 bf6060f..1492ad4 100644 (file)
@@ -55,12 +55,6 @@ source "drivers/hid/usbhid/Kconfig"
 menu "Special HID drivers"
        depends on HID
 
-config HID_3M_PCT
-       tristate "3M PCT touchscreen"
-       depends on USB_HID
-       ---help---
-       Support for 3M PCT touch screens.
-
 config HID_A4TECH
        tristate "A4 tech mice" if EXPERT
        depends on USB_HID
@@ -289,6 +283,7 @@ config HID_MULTITOUCH
          Generic support for HID multitouch panels.
 
          Say Y here if you have one of the following devices:
+         - 3M PCT touch screens
          - Cando dual touch panel
          - Cypress TrueTouch panels
          - Hanvon dual touch panels
index f8464c7..95b874d 100644 (file)
@@ -25,7 +25,6 @@ ifdef CONFIG_LOGIWII_FF
        hid-logitech-y  += hid-lg4ff.o
 endif
 
-obj-$(CONFIG_HID_3M_PCT)       += hid-3m-pct.o
 obj-$(CONFIG_HID_A4TECH)       += hid-a4tech.o
 obj-$(CONFIG_HID_ACRUX_FF)     += hid-axff.o
 obj-$(CONFIG_HID_APPLE)                += hid-apple.o
index eabfd1d..f2995ca 100644 (file)
  *  Copyright (c) 2010 Henrik Rydberg <rydberg@euromail.se>
  *  Copyright (c) 2010 Canonical, Ltd.
  *
+ *  This code is partly based on hid-3m-pct.c:
+ *
+ *  Copyright (c) 2009-2010 Stephane Chatty <chatty@enac.fr>
+ *  Copyright (c) 2010      Henrik Rydberg <rydberg@euromail.se>
+ *  Copyright (c) 2010      Canonical, Ltd.
+ *
  */
 
 /*
@@ -69,6 +75,8 @@ struct mt_class {
        __s32 name;     /* MT_CLS */
        __s32 quirks;
        __s32 sn_move;  /* Signal/noise ratio for move events */
+       __s32 sn_width; /* Signal/noise ratio for width events */
+       __s32 sn_height;        /* Signal/noise ratio for height events */
        __s32 sn_pressure;      /* Signal/noise ratio for pressure events */
        __u8 maxcontacts;
 };
@@ -80,6 +88,7 @@ struct mt_class {
 #define MT_CLS_CYPRESS                         4
 #define MT_CLS_EGALAX                          5
 #define MT_CLS_STANTUM                         6
+#define MT_CLS_3M                              7
 
 #define MT_DEFAULT_MAXCONTACT  10
 
@@ -141,6 +150,12 @@ struct mt_class mt_classes[] = {
        },
        { .name = MT_CLS_STANTUM,
                .quirks = MT_QUIRK_VALID_IS_CONFIDENCE },
+       { .name = MT_CLS_3M,
+               .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
+                       MT_QUIRK_SLOT_IS_CONTACTID,
+               .sn_move = 2048,
+               .sn_width = 128,
+               .sn_height = 128 },
 
        { }
 };
@@ -230,11 +245,15 @@ static int mt_input_mapping(struct hid_device *hdev, struct hid_input *hi,
                case HID_DG_WIDTH:
                        hid_map_usage(hi, usage, bit, max,
                                        EV_ABS, ABS_MT_TOUCH_MAJOR);
+                       set_abs(hi->input, ABS_MT_TOUCH_MAJOR, field,
+                               cls->sn_width);
                        td->last_slot_field = usage->hid;
                        return 1;
                case HID_DG_HEIGHT:
                        hid_map_usage(hi, usage, bit, max,
                                        EV_ABS, ABS_MT_TOUCH_MINOR);
+                       set_abs(hi->input, ABS_MT_TOUCH_MINOR, field,
+                               cls->sn_height);
                        input_set_abs_params(hi->input,
                                        ABS_MT_ORIENTATION, 0, 1, 0, 0);
                        td->last_slot_field = usage->hid;
@@ -332,11 +351,18 @@ static void mt_emit_event(struct mt_device *td, struct input_dev *input)
                input_mt_report_slot_state(input, MT_TOOL_FINGER,
                        s->touch_state);
                if (s->touch_state) {
+                       /* this finger is on the screen */
+                       int wide = (s->w > s->h);
+                       /* divided by two to match visual scale of touch */
+                       int major = max(s->w, s->h) >> 1;
+                       int minor = min(s->w, s->h) >> 1;
+
                        input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
                        input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
+                       input_event(input, EV_ABS, ABS_MT_ORIENTATION, wide);
                        input_event(input, EV_ABS, ABS_MT_PRESSURE, s->p);
-                       input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, s->w);
-                       input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, s->h);
+                       input_event(input, EV_ABS, ABS_MT_TOUCH_MAJOR, major);
+                       input_event(input, EV_ABS, ABS_MT_TOUCH_MINOR, minor);
                }
                s->seen_in_this_frame = false;
 
@@ -398,6 +424,15 @@ static int mt_event(struct hid_device *hid, struct hid_field *field,
                        break;
 
                default:
+                       if (td->last_field_index
+                               && field->index == td->last_field_index)
+                               /* we reach here when the last field in the
+                                * report is not related to multitouch.
+                                * This is not good. As a temporary solution,
+                                * we trigger our mt event completion and
+                                * ignore the field.
+                                */
+                               break;
                        /* fallback to the generic hidinput handling */
                        return 0;
                }
@@ -513,6 +548,14 @@ static void mt_remove(struct hid_device *hdev)
 
 static const struct hid_device_id mt_devices[] = {
 
+       /* 3M panels */
+       { .driver_data = MT_CLS_3M,
+               HID_USB_DEVICE(USB_VENDOR_ID_3M,
+                       USB_DEVICE_ID_3M1968) },
+       { .driver_data = MT_CLS_3M,
+               HID_USB_DEVICE(USB_VENDOR_ID_3M,
+                       USB_DEVICE_ID_3M2256) },
+
        /* Cando panels */
        { .driver_data = MT_CLS_DUAL_INRANGE_CONTACTNUMBER,
                HID_USB_DEVICE(USB_VENDOR_ID_CANDO,