Input: wacom - collect device quirks into single function
[pandora-kernel.git] / drivers / input / tablet / wacom_sys.c
index 42ba369..fc6fd53 100644 (file)
@@ -195,17 +195,30 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
                                                        features->pktlen = WACOM_PKGLEN_TPC2FG;
                                                        features->device_type = BTN_TOOL_TRIPLETAP;
                                                }
-                                               features->x_max =
-                                                       get_unaligned_le16(&report[i + 3]);
-                                               features->x_phy =
-                                                       get_unaligned_le16(&report[i + 6]);
-                                               features->unit = report[i + 9];
-                                               features->unitExpo = report[i + 11];
-                                               i += 12;
+                                               if (features->type == BAMBOO_PT) {
+                                                       /* need to reset back */
+                                                       features->pktlen = WACOM_PKGLEN_BBTOUCH;
+                                                       features->device_type = BTN_TOOL_TRIPLETAP;
+                                                       features->x_phy =
+                                                               get_unaligned_le16(&report[i + 5]);
+                                                       features->x_max =
+                                                               get_unaligned_le16(&report[i + 8]);
+                                                       i += 15;
+                                               } else {
+                                                       features->x_max =
+                                                               get_unaligned_le16(&report[i + 3]);
+                                                       features->x_phy =
+                                                               get_unaligned_le16(&report[i + 6]);
+                                                       features->unit = report[i + 9];
+                                                       features->unitExpo = report[i + 11];
+                                                       i += 12;
+                                               }
                                        } else if (pen) {
                                                /* penabled only accepts exact bytes of data */
                                                if (features->type == TABLETPC2FG)
                                                        features->pktlen = WACOM_PKGLEN_GRAPHIRE;
+                                               if (features->type == BAMBOO_PT)
+                                                       features->pktlen = WACOM_PKGLEN_BBFUN;
                                                features->device_type = BTN_TOOL_PEN;
                                                features->x_max =
                                                        get_unaligned_le16(&report[i + 3]);
@@ -234,6 +247,15 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
                                                        features->y_phy =
                                                                get_unaligned_le16(&report[i + 6]);
                                                        i += 7;
+                                               } else if (features->type == BAMBOO_PT) {
+                                                       /* need to reset back */
+                                                       features->pktlen = WACOM_PKGLEN_BBTOUCH;
+                                                       features->device_type = BTN_TOOL_TRIPLETAP;
+                                                       features->y_phy =
+                                                               get_unaligned_le16(&report[i + 3]);
+                                                       features->y_max =
+                                                               get_unaligned_le16(&report[i + 6]);
+                                                       i += 12;
                                                } else {
                                                        features->y_max =
                                                                features->x_max;
@@ -245,6 +267,8 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
                                                /* penabled only accepts exact bytes of data */
                                                if (features->type == TABLETPC2FG)
                                                        features->pktlen = WACOM_PKGLEN_GRAPHIRE;
+                                               if (features->type == BAMBOO_PT)
+                                                       features->pktlen = WACOM_PKGLEN_BBFUN;
                                                features->device_type = BTN_TOOL_PEN;
                                                features->y_max =
                                                        get_unaligned_le16(&report[i + 3]);
@@ -333,11 +357,16 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
        struct usb_host_interface *interface = intf->cur_altsetting;
        struct hid_descriptor *hid_desc;
 
-       /* default device to penabled */
+       /* default features */
        features->device_type = BTN_TOOL_PEN;
+       features->x_fuzz = 4;
+       features->y_fuzz = 4;
+       features->pressure_fuzz = 0;
+       features->distance_fuzz = 0;
 
        /* only Tablet PCs need to retrieve the info */
-       if ((features->type != TABLETPC) && (features->type != TABLETPC2FG))
+       if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
+           (features->type != BAMBOO_PT))
                goto out;
 
        if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
@@ -352,12 +381,6 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
        if (error)
                goto out;
 
-       /* touch device found but size is not defined. use default */
-       if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) {
-               features->x_max = 1023;
-               features->y_max = 1023;
-       }
-
  out:
        return error;
 }
@@ -493,9 +516,11 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
        if (error)
                goto fail2;
 
+       wacom_setup_device_quirks(features);
+
        strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
 
-       if (features->type == TABLETPC || features->type == TABLETPC2FG) {
+       if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
                /* Append the device type to the name */
                strlcat(wacom_wac->name,
                        features->device_type == BTN_TOOL_PEN ?