These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / hid / wacom_wac.c
index adf959d..01a4f05 100644 (file)
@@ -69,7 +69,7 @@ static void wacom_notify_battery(struct wacom_wac *wacom_wac,
 static int wacom_penpartner_irq(struct wacom_wac *wacom)
 {
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
 
        switch (data[0]) {
        case 1:
@@ -114,7 +114,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
 {
        struct wacom_features *features = &wacom->features;
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
        int prox, pressure;
 
        if (data[0] != WACOM_REPORT_PENABLED) {
@@ -125,68 +125,54 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
 
        prox = data[1] & 0x40;
 
-       if (prox) {
-               wacom->id[0] = ERASER_DEVICE_ID;
-               pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
-               if (features->pressure_max > 255)
-                       pressure = (pressure << 1) | ((data[4] >> 6) & 1);
-               pressure += (features->pressure_max + 1) / 2;
-
-               /*
-                * if going from out of proximity into proximity select between the eraser
-                * and the pen based on the state of the stylus2 button, choose eraser if
-                * pressed else choose pen. if not a proximity change from out to in, send
-                * an out of proximity for previous tool then a in for new tool.
-                */
-               if (!wacom->tool[0]) {
-                       /* Eraser bit set for DTF */
-                       if (data[1] & 0x10)
-                               wacom->tool[1] = BTN_TOOL_RUBBER;
-                       else
-                               /* Going into proximity select tool */
-                               wacom->tool[1] = (data[4] & 0x20) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
-               } else {
-                       /* was entered with stylus2 pressed */
-                       if (wacom->tool[1] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
-                               /* report out proximity for previous tool */
-                               input_report_key(input, wacom->tool[1], 0);
-                               input_sync(input);
-                               wacom->tool[1] = BTN_TOOL_PEN;
-                               return 0;
-                       }
+       if (!wacom->id[0]) {
+               if ((data[0] & 0x10) || (data[4] & 0x20)) {
+                       wacom->tool[0] = BTN_TOOL_RUBBER;
+                       wacom->id[0] = ERASER_DEVICE_ID;
                }
-               if (wacom->tool[1] != BTN_TOOL_RUBBER) {
-                       /* Unknown tool selected default to pen tool */
-                       wacom->tool[1] = BTN_TOOL_PEN;
+               else {
+                       wacom->tool[0] = BTN_TOOL_PEN;
                        wacom->id[0] = STYLUS_DEVICE_ID;
                }
-               input_report_key(input, wacom->tool[1], prox); /* report in proximity for tool */
-               input_report_abs(input, ABS_MISC, wacom->id[0]); /* report tool id */
-               input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
-               input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
-               input_report_abs(input, ABS_PRESSURE, pressure);
+       }
 
-               input_report_key(input, BTN_TOUCH, data[4] & 0x08);
-               input_report_key(input, BTN_STYLUS, data[4] & 0x10);
-               /* Only allow the stylus2 button to be reported for the pen tool. */
-               input_report_key(input, BTN_STYLUS2, (wacom->tool[1] == BTN_TOOL_PEN) && (data[4] & 0x20));
-       } else {
-               /* report proximity-out of a (valid) tool */
-               if (wacom->tool[1] != BTN_TOOL_RUBBER) {
-                       /* Unknown tool selected default to pen tool */
-                       wacom->tool[1] = BTN_TOOL_PEN;
-               }
-               input_report_key(input, wacom->tool[1], prox);
+       /* If the eraser is in prox, STYLUS2 is always set. If we
+        * mis-detected the type and notice that STYLUS2 isn't set
+        * then force the eraser out of prox and let the pen in.
+        */
+       if (wacom->tool[0] == BTN_TOOL_RUBBER && !(data[4] & 0x20)) {
+               input_report_key(input, BTN_TOOL_RUBBER, 0);
+               input_report_abs(input, ABS_MISC, 0);
+               input_sync(input);
+               wacom->tool[0] = BTN_TOOL_PEN;
+               wacom->id[0] = STYLUS_DEVICE_ID;
        }
 
-       wacom->tool[0] = prox; /* Save proximity state */
+       pressure = (signed char)((data[7] << 1) | ((data[4] >> 2) & 1));
+       if (features->pressure_max > 255)
+               pressure = (pressure << 1) | ((data[4] >> 6) & 1);
+       pressure += (features->pressure_max + 1) / 2;
+
+       input_report_abs(input, ABS_X, data[3] | (data[2] << 7) | ((data[1] & 0x03) << 14));
+       input_report_abs(input, ABS_Y, data[6] | (data[5] << 7) | ((data[4] & 0x03) << 14));
+       input_report_abs(input, ABS_PRESSURE, pressure);
+
+       input_report_key(input, BTN_TOUCH, data[4] & 0x08);
+       input_report_key(input, BTN_STYLUS, data[4] & 0x10);
+       /* Only allow the stylus2 button to be reported for the pen tool. */
+       input_report_key(input, BTN_STYLUS2, (wacom->tool[0] == BTN_TOOL_PEN) && (data[4] & 0x20));
+
+       if (!prox)
+               wacom->id[0] = 0;
+       input_report_key(input, wacom->tool[0], prox);
+       input_report_abs(input, ABS_MISC, wacom->id[0]);
        return 1;
 }
 
 static int wacom_ptu_irq(struct wacom_wac *wacom)
 {
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
 
        if (data[0] != WACOM_REPORT_PENABLED) {
                dev_dbg(input->dev.parent,
@@ -215,7 +201,7 @@ static int wacom_ptu_irq(struct wacom_wac *wacom)
 static int wacom_dtu_irq(struct wacom_wac *wacom)
 {
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
        int prox = data[1] & 0x20;
 
        dev_dbg(input->dev.parent,
@@ -245,7 +231,7 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
 static int wacom_dtus_irq(struct wacom_wac *wacom)
 {
        char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
        unsigned short prox, pressure = 0;
 
        if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
@@ -297,7 +283,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
 {
        struct wacom_features *features = &wacom->features;
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
        struct input_dev *pad_input = wacom->pad_input;
        int battery_capacity, ps_connected;
        int prox;
@@ -464,7 +450,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
 {
        struct wacom_features *features = &wacom->features;
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
        int idx = 0;
 
        /* tool number */
@@ -645,23 +631,149 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
        return 0;
 }
 
+static int wacom_remote_irq(struct wacom_wac *wacom_wac, size_t len)
+{
+       unsigned char *data = wacom_wac->data;
+       struct input_dev *input = wacom_wac->pad_input;
+       struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
+       struct wacom_features *features = &wacom_wac->features;
+       int bat_charging, bat_percent, touch_ring_mode;
+       __u32 serial;
+       int i;
+
+       if (data[0] != WACOM_REPORT_REMOTE) {
+               dev_dbg(input->dev.parent,
+                       "%s: received unknown report #%d", __func__, data[0]);
+               return 0;
+       }
+
+       serial = data[3] + (data[4] << 8) + (data[5] << 16);
+       wacom_wac->id[0] = PAD_DEVICE_ID;
+
+       input_report_key(input, BTN_0, (data[9] & 0x01));
+       input_report_key(input, BTN_1, (data[9] & 0x02));
+       input_report_key(input, BTN_2, (data[9] & 0x04));
+       input_report_key(input, BTN_3, (data[9] & 0x08));
+       input_report_key(input, BTN_4, (data[9] & 0x10));
+       input_report_key(input, BTN_5, (data[9] & 0x20));
+       input_report_key(input, BTN_6, (data[9] & 0x40));
+       input_report_key(input, BTN_7, (data[9] & 0x80));
+
+       input_report_key(input, BTN_8, (data[10] & 0x01));
+       input_report_key(input, BTN_9, (data[10] & 0x02));
+       input_report_key(input, BTN_A, (data[10] & 0x04));
+       input_report_key(input, BTN_B, (data[10] & 0x08));
+       input_report_key(input, BTN_C, (data[10] & 0x10));
+       input_report_key(input, BTN_X, (data[10] & 0x20));
+       input_report_key(input, BTN_Y, (data[10] & 0x40));
+       input_report_key(input, BTN_Z, (data[10] & 0x80));
+
+       input_report_key(input, BTN_BASE, (data[11] & 0x01));
+       input_report_key(input, BTN_BASE2, (data[11] & 0x02));
+
+       if (data[12] & 0x80)
+               input_report_abs(input, ABS_WHEEL, (data[12] & 0x7f));
+       else
+               input_report_abs(input, ABS_WHEEL, 0);
+
+       bat_percent = data[7] & 0x7f;
+       bat_charging = !!(data[7] & 0x80);
+
+       if (data[9] | data[10] | (data[11] & 0x03) | data[12])
+               input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+       else
+               input_report_abs(input, ABS_MISC, 0);
+
+       input_event(input, EV_MSC, MSC_SERIAL, serial);
+
+       /*Which mode select (LED light) is currently on?*/
+       touch_ring_mode = (data[11] & 0xC0) >> 6;
+
+       for (i = 0; i < WACOM_MAX_REMOTES; i++) {
+               if (wacom_wac->serial[i] == serial)
+                       wacom->led.select[i] = touch_ring_mode;
+       }
+
+       if (!wacom->battery &&
+           !(features->quirks & WACOM_QUIRK_BATTERY)) {
+               features->quirks |= WACOM_QUIRK_BATTERY;
+               INIT_WORK(&wacom->work, wacom_battery_work);
+               wacom_schedule_work(wacom_wac);
+       }
+
+       wacom_notify_battery(wacom_wac, bat_percent, bat_charging, 1,
+                            bat_charging);
+
+       return 1;
+}
+
+static int wacom_remote_status_irq(struct wacom_wac *wacom_wac, size_t len)
+{
+       struct wacom *wacom = container_of(wacom_wac, struct wacom, wacom_wac);
+       unsigned char *data = wacom_wac->data;
+       int i;
+
+       if (data[0] != WACOM_REPORT_DEVICE_LIST)
+               return 0;
+
+       for (i = 0; i < WACOM_MAX_REMOTES; i++) {
+               int j = i * 6;
+               int serial = (data[j+6] << 16) + (data[j+5] << 8) + data[j+4];
+               bool connected = data[j+2];
+
+               if (connected) {
+                       int k;
+
+                       if (wacom_wac->serial[i] == serial)
+                               continue;
+
+                       if (wacom_wac->serial[i]) {
+                               wacom_remote_destroy_attr_group(wacom,
+                                                       wacom_wac->serial[i]);
+                       }
+
+                       /* A remote can pair more than once with an EKR,
+                        * check to make sure this serial isn't already paired.
+                        */
+                       for (k = 0; k < WACOM_MAX_REMOTES; k++) {
+                               if (wacom_wac->serial[k] == serial)
+                                       break;
+                       }
+
+                       if (k < WACOM_MAX_REMOTES) {
+                               wacom_wac->serial[i] = serial;
+                               continue;
+                       }
+                       wacom_remote_create_attr_group(wacom, serial, i);
+
+               } else if (wacom_wac->serial[i]) {
+                       wacom_remote_destroy_attr_group(wacom,
+                                                       wacom_wac->serial[i]);
+               }
+       }
+
+       return 0;
+}
+
 static void wacom_intuos_general(struct wacom_wac *wacom)
 {
        struct wacom_features *features = &wacom->features;
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
        unsigned int t;
 
        /* general pen packet */
        if ((data[1] & 0xb8) == 0xa0) {
                t = (data[6] << 2) | ((data[7] >> 6) & 3);
-               if (features->type >= INTUOS4S && features->type <= CINTIQ_HYBRID) {
+               if (features->pressure_max == 2047) {
                        t = (t << 1) | (data[1] & 1);
                }
                input_report_abs(input, ABS_PRESSURE, t);
-               input_report_abs(input, ABS_TILT_X,
+               if (features->type != INTUOSHT2) {
+                   input_report_abs(input, ABS_TILT_X,
                                 (((data[7] << 1) & 0x7e) | (data[8] >> 7)) - 64);
-               input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
+                   input_report_abs(input, ABS_TILT_Y, (data[8] & 0x7f) - 64);
+               }
                input_report_key(input, BTN_STYLUS, data[1] & 2);
                input_report_key(input, BTN_STYLUS2, data[1] & 4);
                input_report_key(input, BTN_TOUCH, t > 10);
@@ -681,7 +793,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
 {
        struct wacom_features *features = &wacom->features;
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
        unsigned int t;
        int idx = 0, result;
 
@@ -689,6 +801,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
            data[0] != WACOM_REPORT_INTUOSREAD &&
            data[0] != WACOM_REPORT_INTUOSWRITE &&
            data[0] != WACOM_REPORT_INTUOSPAD &&
+           data[0] != WACOM_REPORT_INTUOS_PEN &&
            data[0] != WACOM_REPORT_CINTIQ &&
            data[0] != WACOM_REPORT_CINTIQPAD &&
            data[0] != WACOM_REPORT_INTUOS5PAD) {
@@ -838,6 +951,27 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
                        } else {
                                input_report_abs(input, ABS_MISC, 0);
                        }
+
+               } else if (features->type == CINTIQ_COMPANION_2) {
+                       input_report_key(input, BTN_1, (data[1] & 0x02));
+                       input_report_key(input, BTN_2, (data[2] & 0x01));
+                       input_report_key(input, BTN_3, (data[2] & 0x02));
+                       input_report_key(input, BTN_4, (data[2] & 0x04));
+                       input_report_key(input, BTN_5, (data[2] & 0x08));
+                       input_report_key(input, BTN_6, (data[1] & 0x04));
+
+                       input_report_key(input, BTN_7, (data[2] & 0x10));  /* Right  */
+                       input_report_key(input, BTN_8, (data[2] & 0x20));  /* Up         */
+                       input_report_key(input, BTN_9, (data[2] & 0x40));  /* Left   */
+                       input_report_key(input, BTN_A, (data[2] & 0x80));  /* Down   */
+                       input_report_key(input, BTN_0, (data[1] & 0x01));  /* Center */
+
+                       if (data[2] | (data[1] & 0x07)) {
+                               input_report_abs(input, ABS_MISC, PAD_DEVICE_ID);
+                       } else {
+                               input_report_abs(input, ABS_MISC, 0);
+                       }
+
                } else if (features->type >= INTUOS5S && features->type <= INTUOSPL) {
                        int i;
 
@@ -1025,7 +1159,7 @@ static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
        memcpy(wacom->data, data, 10);
        wacom_intuos_irq(wacom);
 
-       input_sync(wacom->input);
+       input_sync(wacom->pen_input);
        if (wacom->pad_input)
                input_sync(wacom->pad_input);
 }
@@ -1057,7 +1191,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
                                     ps_connected);
                break;
        default:
-               dev_dbg(wacom->input->dev.parent,
+               dev_dbg(wacom->pen_input->dev.parent,
                                "Unknown report: %d,%d size:%zu\n",
                                data[0], data[1], len);
                return 0;
@@ -1067,7 +1201,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
 
 static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
 {
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->touch_input;
        unsigned touch_max = wacom->features.touch_max;
        int count = 0;
        int i;
@@ -1075,9 +1209,8 @@ static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
        if (!touch_max)
                return 0;
 
-       /* non-HID_GENERIC single touch input doesn't call this routine */
-       if ((touch_max == 1) && (wacom->features.type == HID_GENERIC))
-               return wacom->hid_data.tipswitch &&
+       if (touch_max == 1)
+               return test_bit(BTN_TOUCH, input->key) &&
                       !wacom->shared->stylus_in_proximity;
 
        for (i = 0; i < input->mt->num_slots; i++) {
@@ -1092,7 +1225,7 @@ static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
 
 static int wacom_24hdt_irq(struct wacom_wac *wacom)
 {
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->touch_input;
        unsigned char *data = wacom->data;
        int i;
        int current_num_contacts = data[61];
@@ -1160,7 +1293,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
 
 static int wacom_mt_touch(struct wacom_wac *wacom)
 {
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->touch_input;
        unsigned char *data = wacom->data;
        int i;
        int current_num_contacts = data[2];
@@ -1211,7 +1344,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
 
 static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
 {
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->touch_input;
        unsigned char *data = wacom->data;
        int i;
 
@@ -1240,7 +1373,7 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
 static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
 {
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->touch_input;
        bool prox = !wacom->shared->stylus_in_proximity;
        int x = 0, y = 0;
 
@@ -1276,7 +1409,7 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
 static int wacom_tpc_pen(struct wacom_wac *wacom)
 {
        unsigned char *data = wacom->data;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
        bool prox = data[1] & 0x20;
 
        if (!wacom->shared->stylus_in_proximity) /* first in prox */
@@ -1305,8 +1438,12 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
 {
        unsigned char *data = wacom->data;
 
-       dev_dbg(wacom->input->dev.parent,
-               "%s: received report #%d\n", __func__, data[0]);
+       if (wacom->pen_input)
+               dev_dbg(wacom->pen_input->dev.parent,
+                       "%s: received report #%d\n", __func__, data[0]);
+       else if (wacom->touch_input)
+               dev_dbg(wacom->touch_input->dev.parent,
+                       "%s: received report #%d\n", __func__, data[0]);
 
        switch (len) {
        case WACOM_PKGLEN_TPC1FG:
@@ -1338,11 +1475,9 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
        return 0;
 }
 
-static void wacom_map_usage(struct wacom *wacom, struct hid_usage *usage,
+static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
                struct hid_field *field, __u8 type, __u16 code, int fuzz)
 {
-       struct wacom_wac *wacom_wac = &wacom->wacom_wac;
-       struct input_dev *input = wacom_wac->input;
        int fmin = field->logical_minimum;
        int fmax = field->logical_maximum;
 
@@ -1370,36 +1505,38 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
                struct hid_field *field, struct hid_usage *usage)
 {
        struct wacom *wacom = hid_get_drvdata(hdev);
+       struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+       struct input_dev *input = wacom_wac->pen_input;
 
        switch (usage->hid) {
        case HID_GD_X:
-               wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4);
+               wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
                break;
        case HID_GD_Y:
-               wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4);
+               wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
                break;
        case HID_DG_TIPPRESSURE:
-               wacom_map_usage(wacom, usage, field, EV_ABS, ABS_PRESSURE, 0);
+               wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
                break;
        case HID_DG_INRANGE:
-               wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
+               wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
                break;
        case HID_DG_INVERT:
-               wacom_map_usage(wacom, usage, field, EV_KEY,
+               wacom_map_usage(input, usage, field, EV_KEY,
                                BTN_TOOL_RUBBER, 0);
                break;
        case HID_DG_ERASER:
        case HID_DG_TIPSWITCH:
-               wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0);
+               wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
                break;
        case HID_DG_BARRELSWITCH:
-               wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS, 0);
+               wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
                break;
        case HID_DG_BARRELSWITCH2:
-               wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS2, 0);
+               wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
                break;
        case HID_DG_TOOLSERIALNUMBER:
-               wacom_map_usage(wacom, usage, field, EV_MSC, MSC_SERIAL, 0);
+               wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
                break;
        }
 }
@@ -1409,7 +1546,7 @@ static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
 {
        struct wacom *wacom = hid_get_drvdata(hdev);
        struct wacom_wac *wacom_wac = &wacom->wacom_wac;
-       struct input_dev *input = wacom_wac->input;
+       struct input_dev *input = wacom_wac->pen_input;
 
        /* checking which Tool / tip switch to send */
        switch (usage->hid) {
@@ -1434,12 +1571,18 @@ static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
        return 0;
 }
 
+static void wacom_wac_pen_pre_report(struct hid_device *hdev,
+               struct hid_report *report)
+{
+       return;
+}
+
 static void wacom_wac_pen_report(struct hid_device *hdev,
                struct hid_report *report)
 {
        struct wacom *wacom = hid_get_drvdata(hdev);
        struct wacom_wac *wacom_wac = &wacom->wacom_wac;
-       struct input_dev *input = wacom_wac->input;
+       struct input_dev *input = wacom_wac->pen_input;
        bool prox = wacom_wac->hid_data.inrange_state;
 
        if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */
@@ -1468,25 +1611,33 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
        struct wacom *wacom = hid_get_drvdata(hdev);
        struct wacom_wac *wacom_wac = &wacom->wacom_wac;
        struct wacom_features *features = &wacom_wac->features;
+       struct input_dev *input = wacom_wac->touch_input;
        unsigned touch_max = wacom_wac->features.touch_max;
 
        switch (usage->hid) {
        case HID_GD_X:
                features->last_slot_field = usage->hid;
                if (touch_max == 1)
-                       wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4);
+                       wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
                else
-                       wacom_map_usage(wacom, usage, field, EV_ABS,
+                       wacom_map_usage(input, usage, field, EV_ABS,
                                        ABS_MT_POSITION_X, 4);
                break;
        case HID_GD_Y:
                features->last_slot_field = usage->hid;
                if (touch_max == 1)
-                       wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4);
+                       wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
                else
-                       wacom_map_usage(wacom, usage, field, EV_ABS,
+                       wacom_map_usage(input, usage, field, EV_ABS,
                                        ABS_MT_POSITION_Y, 4);
                break;
+       case HID_DG_WIDTH:
+       case HID_DG_HEIGHT:
+               features->last_slot_field = usage->hid;
+               wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MAJOR, 0);
+               wacom_map_usage(input, usage, field, EV_ABS, ABS_MT_TOUCH_MINOR, 0);
+               input_set_abs_params(input, ABS_MT_ORIENTATION, 0, 1, 0, 0);
+               break;
        case HID_DG_CONTACTID:
                features->last_slot_field = usage->hid;
                break;
@@ -1498,7 +1649,12 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
                break;
        case HID_DG_TIPSWITCH:
                features->last_slot_field = usage->hid;
-               wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0);
+               wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
+               break;
+       case HID_DG_CONTACTCOUNT:
+               wacom_wac->hid_data.cc_report = field->report->id;
+               wacom_wac->hid_data.cc_index = field->index;
+               wacom_wac->hid_data.cc_value_index = usage->usage_index;
                break;
        }
 }
@@ -1511,6 +1667,10 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
        bool prox = hid_data->tipswitch &&
                    !wacom_wac->shared->stylus_in_proximity;
 
+       wacom_wac->hid_data.num_received++;
+       if (wacom_wac->hid_data.num_received > wacom_wac->hid_data.num_expected)
+               return;
+
        if (mt) {
                int slot;
 
@@ -1527,6 +1687,13 @@ static void wacom_wac_finger_slot(struct wacom_wac *wacom_wac,
                                 hid_data->x);
                input_report_abs(input, mt ? ABS_MT_POSITION_Y : ABS_Y,
                                 hid_data->y);
+
+               if (test_bit(ABS_MT_TOUCH_MAJOR, input->absbit)) {
+                       input_report_abs(input, ABS_MT_TOUCH_MAJOR, max(hid_data->width, hid_data->height));
+                       input_report_abs(input, ABS_MT_TOUCH_MINOR, min(hid_data->width, hid_data->height));
+                       if (hid_data->width != hid_data->height)
+                               input_report_abs(input, ABS_MT_ORIENTATION, hid_data->width <= hid_data->height ? 0 : 1);
+               }
        }
 }
 
@@ -1543,6 +1710,12 @@ static int wacom_wac_finger_event(struct hid_device *hdev,
        case HID_GD_Y:
                wacom_wac->hid_data.y = value;
                break;
+       case HID_DG_WIDTH:
+               wacom_wac->hid_data.width = value;
+               break;
+       case HID_DG_HEIGHT:
+               wacom_wac->hid_data.height = value;
+               break;
        case HID_DG_CONTACTID:
                wacom_wac->hid_data.id = value;
                break;
@@ -1554,24 +1727,75 @@ static int wacom_wac_finger_event(struct hid_device *hdev,
 
        if (usage->usage_index + 1 == field->report_count) {
                if (usage->hid == wacom_wac->features.last_slot_field)
-                       wacom_wac_finger_slot(wacom_wac, wacom_wac->input);
+                       wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
        }
 
        return 0;
 }
 
+static void wacom_wac_finger_pre_report(struct hid_device *hdev,
+               struct hid_report *report)
+{
+       struct wacom *wacom = hid_get_drvdata(hdev);
+       struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+       struct hid_data* hid_data = &wacom_wac->hid_data;
+
+       if (hid_data->cc_report != 0 &&
+           hid_data->cc_report != report->id) {
+               int i;
+
+               hid_data->cc_report = report->id;
+               hid_data->cc_index = -1;
+               hid_data->cc_value_index = -1;
+
+               for (i = 0; i < report->maxfield; i++) {
+                       struct hid_field *field = report->field[i];
+                       int j;
+
+                       for (j = 0; j < field->maxusage; j++) {
+                               if (field->usage[j].hid == HID_DG_CONTACTCOUNT) {
+                                       hid_data->cc_index = i;
+                                       hid_data->cc_value_index = j;
+
+                                       /* break */
+                                       i = report->maxfield;
+                                       j = field->maxusage;
+                               }
+                       }
+               }
+       }
+       if (hid_data->cc_report != 0 &&
+           hid_data->cc_index >= 0) {
+               struct hid_field *field = report->field[hid_data->cc_index];
+               int value = field->value[hid_data->cc_value_index];
+               if (value)
+                       hid_data->num_expected = value;
+       }
+       else {
+               hid_data->num_expected = wacom_wac->features.touch_max;
+       }
+}
+
 static void wacom_wac_finger_report(struct hid_device *hdev,
                struct hid_report *report)
 {
        struct wacom *wacom = hid_get_drvdata(hdev);
        struct wacom_wac *wacom_wac = &wacom->wacom_wac;
-       struct input_dev *input = wacom_wac->input;
+       struct input_dev *input = wacom_wac->touch_input;
        unsigned touch_max = wacom_wac->features.touch_max;
 
+       /* If more packets of data are expected, give us a chance to
+        * process them rather than immediately syncing a partial
+        * update.
+        */
+       if (wacom_wac->hid_data.num_received < wacom_wac->hid_data.num_expected)
+               return;
+
        if (touch_max > 1)
                input_mt_sync_frame(input);
 
        input_sync(input);
+       wacom_wac->hid_data.num_received = 0;
 
        /* keep touch state for pen event */
        wacom_wac->shared->touch_down = wacom_wac_finger_count_touches(wacom_wac);
@@ -1582,10 +1806,10 @@ void wacom_wac_usage_mapping(struct hid_device *hdev,
 {
        struct wacom *wacom = hid_get_drvdata(hdev);
        struct wacom_wac *wacom_wac = &wacom->wacom_wac;
-       struct input_dev *input = wacom_wac->input;
 
        /* currently, only direct devices have proper hid report descriptors */
-       __set_bit(INPUT_PROP_DIRECT, input->propbit);
+       __set_bit(INPUT_PROP_DIRECT, wacom_wac->pen_input->propbit);
+       __set_bit(INPUT_PROP_DIRECT, wacom_wac->touch_input->propbit);
 
        if (WACOM_PEN_FIELD(field))
                return wacom_wac_pen_usage_mapping(hdev, field, usage);
@@ -1611,6 +1835,25 @@ int wacom_wac_event(struct hid_device *hdev, struct hid_field *field,
        return 0;
 }
 
+static void wacom_report_events(struct hid_device *hdev, struct hid_report *report)
+{
+       int r;
+
+       for (r = 0; r < report->maxfield; r++) {
+               struct hid_field *field;
+               unsigned count, n;
+
+               field = report->field[r];
+               count = field->report_count;
+
+               if (!(HID_MAIN_ITEM_VARIABLE & field->flags))
+                       continue;
+
+               for (n = 0; n < count; n++)
+                       wacom_wac_event(hdev, field, &field->usage[n], field->value[n]);
+       }
+}
+
 void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
 {
        struct wacom *wacom = hid_get_drvdata(hdev);
@@ -1620,6 +1863,14 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
        if (wacom_wac->features.type != HID_GENERIC)
                return;
 
+       if (WACOM_PEN_FIELD(field))
+               wacom_wac_pen_pre_report(hdev, report);
+
+       if (WACOM_FINGER_FIELD(field))
+               wacom_wac_finger_pre_report(hdev, report);
+
+       wacom_report_events(hdev, report);
+
        if (WACOM_PEN_FIELD(field))
                return wacom_wac_pen_report(hdev, report);
 
@@ -1630,7 +1881,7 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
 static int wacom_bpt_touch(struct wacom_wac *wacom)
 {
        struct wacom_features *features = &wacom->features;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->touch_input;
        struct input_dev *pad_input = wacom->pad_input;
        unsigned char *data = wacom->data;
        int i;
@@ -1678,7 +1929,7 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
 static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
 {
        struct wacom_features *features = &wacom->features;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->touch_input;
        bool touch = data[1] & 0x80;
        int slot = input_mt_get_slot_by_key(input, data[0]);
 
@@ -1695,7 +1946,7 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
                int y = (data[3] << 4) | (data[4] & 0x0f);
                int width, height;
 
-               if (features->type >= INTUOSPS && features->type <= INTUOSPL) {
+               if (features->type >= INTUOSPS && features->type <= INTUOSHT2) {
                        width  = data[5] * 100;
                        height = data[6] * 100;
                } else {
@@ -1723,7 +1974,7 @@ static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
        struct input_dev *input = wacom->pad_input;
        struct wacom_features *features = &wacom->features;
 
-       if (features->type == INTUOSHT) {
+       if (features->type == INTUOSHT || features->type == INTUOSHT2) {
                input_report_key(input, BTN_LEFT, (data[1] & 0x02) != 0);
                input_report_key(input, BTN_BACK, (data[1] & 0x08) != 0);
        } else {
@@ -1736,10 +1987,9 @@ static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
 
 static int wacom_bpt3_touch(struct wacom_wac *wacom)
 {
-       struct input_dev *input = wacom->input;
        unsigned char *data = wacom->data;
        int count = data[1] & 0x07;
-       int i;
+       int  touch_changed = 0, i;
 
        if (data[0] != 0x02)
            return 0;
@@ -1749,14 +1999,19 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
                int offset = (8 * i) + 2;
                int msg_id = data[offset];
 
-               if (msg_id >= 2 && msg_id <= 17)
+               if (msg_id >= 2 && msg_id <= 17) {
                        wacom_bpt3_touch_msg(wacom, data + offset);
-               else if (msg_id == 128)
+                       touch_changed++;
+               } else if (msg_id == 128)
                        wacom_bpt3_button_msg(wacom, data + offset);
 
        }
-       input_mt_sync_frame(input);
-       wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
+
+       /* only update touch if we actually have a touchpad and touch data changed */
+       if (wacom->touch_registered && touch_changed) {
+               input_mt_sync_frame(wacom->touch_input);
+               wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
+       }
 
        return 1;
 }
@@ -1764,7 +2019,7 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
 static int wacom_bpt_pen(struct wacom_wac *wacom)
 {
        struct wacom_features *features = &wacom->features;
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->pen_input;
        unsigned char *data = wacom->data;
        int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
 
@@ -1834,7 +2089,12 @@ static int wacom_bpt_pen(struct wacom_wac *wacom)
 
 static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
 {
-       if (len == WACOM_PKGLEN_BBTOUCH)
+       struct wacom_features *features = &wacom->features;
+
+       if ((features->type == INTUOSHT2) &&
+           (features->device_type & WACOM_DEVICETYPE_PEN))
+               return wacom_intuos_irq(wacom);
+       else if (len == WACOM_PKGLEN_BBTOUCH)
                return wacom_bpt_touch(wacom);
        else if (len == WACOM_PKGLEN_BBTOUCH3)
                return wacom_bpt3_touch(wacom);
@@ -1873,7 +2133,7 @@ static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
 static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
                unsigned char *data)
 {
-       struct input_dev *input = wacom->input;
+       struct input_dev *input = wacom->touch_input;
        unsigned char *finger_data, prefix;
        unsigned id;
        int x, y;
@@ -1941,7 +2201,8 @@ static int wacom_wireless_irq(struct wacom_wac *wacom, size_t len)
        if (connected) {
                int pid, battery, charging;
 
-               if ((wacom->shared->type == INTUOSHT) &&
+               if ((wacom->shared->type == INTUOSHT ||
+                   wacom->shared->type == INTUOSHT2) &&
                    wacom->shared->touch_input &&
                    wacom->shared->touch_max) {
                        input_report_switch(wacom->shared->touch_input,
@@ -1979,7 +2240,8 @@ static int wacom_status_irq(struct wacom_wac *wacom_wac, size_t len)
        if (data[0] != WACOM_REPORT_USB)
                return 0;
 
-       if (features->type == INTUOSHT &&
+       if ((features->type == INTUOSHT ||
+           features->type == INTUOSHT2) &&
            wacom_wac->shared->touch_input &&
            features->touch_max) {
                input_report_switch(wacom_wac->shared->touch_input,
@@ -2060,6 +2322,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
        case WACOM_27QHD:
        case DTK:
        case CINTIQ_HYBRID:
+       case CINTIQ_COMPANION_2:
                sync = wacom_intuos_irq(wacom_wac);
                break;
 
@@ -2096,7 +2359,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
                break;
 
        case BAMBOO_PT:
+       case BAMBOO_PEN:
+       case BAMBOO_TOUCH:
        case INTUOSHT:
+       case INTUOSHT2:
                if (wacom_wac->data[0] == WACOM_REPORT_USB)
                        sync = wacom_status_irq(wacom_wac, len);
                else
@@ -2111,34 +2377,53 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
                sync = wacom_wireless_irq(wacom_wac, len);
                break;
 
+       case REMOTE:
+               if (wacom_wac->data[0] == WACOM_REPORT_DEVICE_LIST)
+                       sync = wacom_remote_status_irq(wacom_wac, len);
+               else
+                       sync = wacom_remote_irq(wacom_wac, len);
+               break;
+
        default:
                sync = false;
                break;
        }
 
        if (sync) {
-               input_sync(wacom_wac->input);
+               if (wacom_wac->pen_input)
+                       input_sync(wacom_wac->pen_input);
+               if (wacom_wac->touch_input)
+                       input_sync(wacom_wac->touch_input);
                if (wacom_wac->pad_input)
                        input_sync(wacom_wac->pad_input);
        }
 }
 
-static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
+static void wacom_setup_basic_pro_pen(struct wacom_wac *wacom_wac)
 {
-       struct input_dev *input_dev = wacom_wac->input;
+       struct input_dev *input_dev = wacom_wac->pen_input;
 
        input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
 
-       __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
        __set_bit(BTN_TOOL_PEN, input_dev->keybit);
-       __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
-       __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
-       __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
        __set_bit(BTN_STYLUS, input_dev->keybit);
        __set_bit(BTN_STYLUS2, input_dev->keybit);
 
        input_set_abs_params(input_dev, ABS_DISTANCE,
                             0, wacom_wac->features.distance_max, 0, 0);
+}
+
+static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
+{
+       struct input_dev *input_dev = wacom_wac->pen_input;
+
+       wacom_setup_basic_pro_pen(wacom_wac);
+
+       __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
+       __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
+       __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
+       __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
+
        input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
        input_set_abs_params(input_dev, ABS_TILT_X, -64, 63, 0, 0);
        input_abs_set_res(input_dev, ABS_TILT_X, 57);
@@ -2148,7 +2433,7 @@ static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
 
 static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
 {
-       struct input_dev *input_dev = wacom_wac->input;
+       struct input_dev *input_dev = wacom_wac->pen_input;
 
        input_set_capability(input_dev, EV_REL, REL_WHEEL);
 
@@ -2167,15 +2452,62 @@ static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
        input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
 }
 
-void wacom_setup_device_quirks(struct wacom_features *features)
+void wacom_setup_device_quirks(struct wacom *wacom)
 {
+       struct wacom_features *features = &wacom->wacom_wac.features;
+
+       /* The pen and pad share the same interface on most devices */
+       if (features->type == GRAPHIRE_BT || features->type == WACOM_G4 ||
+           features->type == DTUS ||
+           (features->type >= INTUOS3S && features->type <= WACOM_MO)) {
+               if (features->device_type & WACOM_DEVICETYPE_PEN)
+                       features->device_type |= WACOM_DEVICETYPE_PAD;
+       }
 
        /* touch device found but size is not defined. use default */
-       if (features->device_type == BTN_TOOL_FINGER && !features->x_max) {
+       if (features->device_type & WACOM_DEVICETYPE_TOUCH && !features->x_max) {
                features->x_max = 1023;
                features->y_max = 1023;
        }
 
+       /*
+        * Intuos5/Pro and Bamboo 3rd gen have no useful data about its
+        * touch interface in its HID descriptor. If this is the touch
+        * interface (PacketSize of WACOM_PKGLEN_BBTOUCH3), override the
+        * tablet values.
+        */
+       if ((features->type >= INTUOS5S && features->type <= INTUOSPL) ||
+               (features->type >= INTUOSHT && features->type <= BAMBOO_PT)) {
+               if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
+                       if (features->touch_max)
+                               features->device_type |= WACOM_DEVICETYPE_TOUCH;
+                       if (features->type >= INTUOSHT && features->type <= BAMBOO_PT)
+                               features->device_type |= WACOM_DEVICETYPE_PAD;
+
+                       features->x_max = 4096;
+                       features->y_max = 4096;
+               }
+               else if (features->pktlen == WACOM_PKGLEN_BBTOUCH) {
+                       features->device_type |= WACOM_DEVICETYPE_PAD;
+               }
+       }
+
+       /*
+        * Raw Wacom-mode pen and touch events both come from interface
+        * 0, whose HID descriptor has an application usage of 0xFF0D
+        * (i.e., WACOM_VENDORDEFINED_PEN). We route pen packets back
+        * out through the HID_GENERIC device created for interface 1,
+        * so rewrite this one to be of type WACOM_DEVICETYPE_TOUCH.
+        */
+       if (features->type == BAMBOO_PAD)
+               features->device_type = WACOM_DEVICETYPE_TOUCH;
+
+       if (features->type == REMOTE)
+               features->device_type = WACOM_DEVICETYPE_PAD;
+
+       if (wacom->hdev->bus == BUS_BLUETOOTH)
+               features->quirks |= WACOM_QUIRK_BATTERY;
+
        /* quirk for bamboo touch with 2 low res touches */
        if (features->type == BAMBOO_PT &&
            features->pktlen == WACOM_PKGLEN_BBTOUCH) {
@@ -2187,66 +2519,22 @@ void wacom_setup_device_quirks(struct wacom_features *features)
        }
 
        if (features->type == WIRELESS) {
-
-               /* monitor never has input and pen/touch have delayed create */
-               features->quirks |= WACOM_QUIRK_NO_INPUT;
-
-               /* must be monitor interface if no device_type set */
-               if (!features->device_type) {
-                       features->quirks |= WACOM_QUIRK_MONITOR;
+               if (features->device_type == WACOM_DEVICETYPE_WL_MONITOR) {
                        features->quirks |= WACOM_QUIRK_BATTERY;
                }
        }
 }
 
-static void wacom_abs_set_axis(struct input_dev *input_dev,
-                              struct wacom_wac *wacom_wac)
-{
-       struct wacom_features *features = &wacom_wac->features;
-
-       if (features->device_type == BTN_TOOL_PEN) {
-               input_set_abs_params(input_dev, ABS_X, features->x_min,
-                                    features->x_max, features->x_fuzz, 0);
-               input_set_abs_params(input_dev, ABS_Y, features->y_min,
-                                    features->y_max, features->y_fuzz, 0);
-               input_set_abs_params(input_dev, ABS_PRESSURE, 0,
-                       features->pressure_max, features->pressure_fuzz, 0);
-
-               /* penabled devices have fixed resolution for each model */
-               input_abs_set_res(input_dev, ABS_X, features->x_resolution);
-               input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
-       } else {
-               if (features->touch_max == 1) {
-                       input_set_abs_params(input_dev, ABS_X, 0,
-                               features->x_max, features->x_fuzz, 0);
-                       input_set_abs_params(input_dev, ABS_Y, 0,
-                               features->y_max, features->y_fuzz, 0);
-                       input_abs_set_res(input_dev, ABS_X,
-                                         features->x_resolution);
-                       input_abs_set_res(input_dev, ABS_Y,
-                                         features->y_resolution);
-               }
-
-               if (features->touch_max > 1) {
-                       input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
-                               features->x_max, features->x_fuzz, 0);
-                       input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
-                               features->y_max, features->y_fuzz, 0);
-                       input_abs_set_res(input_dev, ABS_MT_POSITION_X,
-                                         features->x_resolution);
-                       input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
-                                         features->y_resolution);
-               }
-       }
-}
-
-int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
+int wacom_setup_pen_input_capabilities(struct input_dev *input_dev,
                                   struct wacom_wac *wacom_wac)
 {
        struct wacom_features *features = &wacom_wac->features;
 
        input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
 
+       if (!(features->device_type & WACOM_DEVICETYPE_PEN))
+               return -ENODEV;
+
        if (features->type == HID_GENERIC)
                /* setup has already been done */
                return 0;
@@ -2254,7 +2542,17 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
        __set_bit(BTN_TOUCH, input_dev->keybit);
        __set_bit(ABS_MISC, input_dev->absbit);
 
-       wacom_abs_set_axis(input_dev, wacom_wac);
+       input_set_abs_params(input_dev, ABS_X, features->x_min,
+                            features->x_max, features->x_fuzz, 0);
+       input_set_abs_params(input_dev, ABS_Y, features->y_min,
+                            features->y_max, features->y_fuzz, 0);
+       input_set_abs_params(input_dev, ABS_PRESSURE, 0,
+               features->pressure_max, features->pressure_fuzz, 0);
+
+       /* penabled devices have fixed resolution for each model */
+       input_abs_set_res(input_dev, ABS_X, features->x_resolution);
+       input_abs_set_res(input_dev, ABS_Y, features->y_resolution);
+
 
        switch (features->type) {
        case GRAPHIRE_BT:
@@ -2292,6 +2590,7 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
        case CINTIQ:
        case WACOM_13HD:
        case CINTIQ_HYBRID:
+       case CINTIQ_COMPANION_2:
                input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
                input_abs_set_res(input_dev, ABS_Z, 287);
                __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
@@ -2323,53 +2622,25 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
        case INTUOSPS:
                __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
 
-               if (features->device_type == BTN_TOOL_PEN) {
-                       input_set_abs_params(input_dev, ABS_DISTANCE, 0,
-                                             features->distance_max,
-                                             0, 0);
-
-                       input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
-                       input_abs_set_res(input_dev, ABS_Z, 287);
+               input_set_abs_params(input_dev, ABS_DISTANCE, 0,
+                                     features->distance_max,
+                                     0, 0);
 
-                       wacom_setup_intuos(wacom_wac);
-               } else if (features->device_type == BTN_TOOL_FINGER) {
-                       __clear_bit(ABS_MISC, input_dev->absbit);
+               input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
+               input_abs_set_res(input_dev, ABS_Z, 287);
 
-                       input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
-                                            0, features->x_max, 0, 0);
-                       input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR,
-                                            0, features->y_max, 0, 0);
-                       input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
-               }
+               wacom_setup_intuos(wacom_wac);
                break;
 
        case WACOM_24HDT:
-               if (features->device_type == BTN_TOOL_FINGER) {
-                       input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
-                       input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
-                       input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
-                       input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
-               }
-               /* fall through */
-
        case WACOM_27QHDT:
        case MTSCREEN:
        case MTTPC:
        case MTTPC_B:
        case TABLETPC2FG:
-               if (features->device_type == BTN_TOOL_FINGER && features->touch_max > 1)
-                       input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
-               /* fall through */
-
        case TABLETPC:
        case TABLETPCE:
                __clear_bit(ABS_MISC, input_dev->absbit);
-
-               __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
-
-               if (features->device_type != BTN_TOOL_PEN)
-                       break;  /* no need to process stylus stuff */
-
                /* fall through */
 
        case DTUS:
@@ -2397,50 +2668,122 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
                break;
 
        case INTUOSHT:
-               if (features->touch_max &&
-                   features->device_type == BTN_TOOL_FINGER) {
-                       input_dev->evbit[0] |= BIT_MASK(EV_SW);
-                       __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
-               }
-               /* fall through */
-
        case BAMBOO_PT:
-               __clear_bit(ABS_MISC, input_dev->absbit);
-
-               if (features->device_type == BTN_TOOL_FINGER) {
-
-                       if (features->touch_max) {
-                               if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
-                                       input_set_abs_params(input_dev,
-                                                    ABS_MT_TOUCH_MAJOR,
-                                                    0, features->x_max, 0, 0);
-                                       input_set_abs_params(input_dev,
-                                                    ABS_MT_TOUCH_MINOR,
-                                                    0, features->y_max, 0, 0);
-                               }
-                               input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
-                       } else {
-                               /* buttons/keys only interface */
-                               __clear_bit(ABS_X, input_dev->absbit);
-                               __clear_bit(ABS_Y, input_dev->absbit);
-                               __clear_bit(BTN_TOUCH, input_dev->keybit);
+       case BAMBOO_PEN:
+       case INTUOSHT2:
+               __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
 
-                               /* PAD is setup by wacom_setup_pad_input_capabilities later */
-                               return 1;
-                       }
-               } else if (features->device_type == BTN_TOOL_PEN) {
-                       __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
-                       __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
+               if (features->type == INTUOSHT2) {
+                       wacom_setup_basic_pro_pen(wacom_wac);
+               } else {
+                       __clear_bit(ABS_MISC, input_dev->absbit);
                        __set_bit(BTN_TOOL_PEN, input_dev->keybit);
+                       __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
                        __set_bit(BTN_STYLUS, input_dev->keybit);
                        __set_bit(BTN_STYLUS2, input_dev->keybit);
                        input_set_abs_params(input_dev, ABS_DISTANCE, 0,
-                                             features->distance_max,
-                                             0, 0);
+                                     features->distance_max,
+                                     0, 0);
                }
                break;
        case BAMBOO_PAD:
                __clear_bit(ABS_MISC, input_dev->absbit);
+               break;
+       }
+       return 0;
+}
+
+int wacom_setup_touch_input_capabilities(struct input_dev *input_dev,
+                                        struct wacom_wac *wacom_wac)
+{
+       struct wacom_features *features = &wacom_wac->features;
+
+       input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
+
+       if (!(features->device_type & WACOM_DEVICETYPE_TOUCH))
+               return -ENODEV;
+
+       if (features->type == HID_GENERIC)
+               /* setup has already been done */
+               return 0;
+
+       __set_bit(BTN_TOUCH, input_dev->keybit);
+
+       if (features->touch_max == 1) {
+               input_set_abs_params(input_dev, ABS_X, 0,
+                       features->x_max, features->x_fuzz, 0);
+               input_set_abs_params(input_dev, ABS_Y, 0,
+                       features->y_max, features->y_fuzz, 0);
+               input_abs_set_res(input_dev, ABS_X,
+                                 features->x_resolution);
+               input_abs_set_res(input_dev, ABS_Y,
+                                 features->y_resolution);
+       }
+       else if (features->touch_max > 1) {
+               input_set_abs_params(input_dev, ABS_MT_POSITION_X, 0,
+                       features->x_max, features->x_fuzz, 0);
+               input_set_abs_params(input_dev, ABS_MT_POSITION_Y, 0,
+                       features->y_max, features->y_fuzz, 0);
+               input_abs_set_res(input_dev, ABS_MT_POSITION_X,
+                                 features->x_resolution);
+               input_abs_set_res(input_dev, ABS_MT_POSITION_Y,
+                                 features->y_resolution);
+       }
+
+       switch (features->type) {
+       case INTUOS5:
+       case INTUOS5L:
+       case INTUOSPM:
+       case INTUOSPL:
+       case INTUOS5S:
+       case INTUOSPS:
+               __set_bit(INPUT_PROP_POINTER, input_dev->propbit);
+
+               input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
+               input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, 0, features->y_max, 0, 0);
+               input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
+               break;
+
+       case WACOM_24HDT:
+               input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, 0, features->x_max, 0, 0);
+               input_set_abs_params(input_dev, ABS_MT_WIDTH_MAJOR, 0, features->x_max, 0, 0);
+               input_set_abs_params(input_dev, ABS_MT_WIDTH_MINOR, 0, features->y_max, 0, 0);
+               input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0);
+               /* fall through */
+
+       case WACOM_27QHDT:
+       case MTSCREEN:
+       case MTTPC:
+       case MTTPC_B:
+       case TABLETPC2FG:
+               input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_DIRECT);
+               /*fall through */
+
+       case TABLETPC:
+       case TABLETPCE:
+               __set_bit(INPUT_PROP_DIRECT, input_dev->propbit);
+               break;
+
+       case INTUOSHT:
+       case INTUOSHT2:
+               input_dev->evbit[0] |= BIT_MASK(EV_SW);
+               __set_bit(SW_MUTE_DEVICE, input_dev->swbit);
+               /* fall through */
+
+       case BAMBOO_PT:
+       case BAMBOO_TOUCH:
+               if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
+                       input_set_abs_params(input_dev,
+                                    ABS_MT_TOUCH_MAJOR,
+                                    0, features->x_max, 0, 0);
+                       input_set_abs_params(input_dev,
+                                    ABS_MT_TOUCH_MINOR,
+                                    0, features->y_max, 0, 0);
+               }
+               input_mt_init_slots(input_dev, features->touch_max, INPUT_MT_POINTER);
+               break;
+
+       case BAMBOO_PAD:
                input_mt_init_slots(input_dev, features->touch_max,
                                    INPUT_MT_POINTER);
                __set_bit(BTN_LEFT, input_dev->keybit);
@@ -2450,11 +2793,26 @@ int wacom_setup_pentouch_input_capabilities(struct input_dev *input_dev,
        return 0;
 }
 
+static void wacom_setup_numbered_buttons(struct input_dev *input_dev,
+                               int button_count)
+{
+       int i;
+
+       for (i = 0; i < button_count && i < 10; i++)
+               __set_bit(BTN_0 + i, input_dev->keybit);
+       for (i = 10; i < button_count && i < 16; i++)
+               __set_bit(BTN_A + (i-10), input_dev->keybit);
+       for (i = 16; i < button_count && i < 18; i++)
+               __set_bit(BTN_BASE + (i-16), input_dev->keybit);
+}
+
 int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
                                   struct wacom_wac *wacom_wac)
 {
        struct wacom_features *features = &wacom_wac->features;
-       int i;
+
+       if (!(features->device_type & WACOM_DEVICETYPE_PAD))
+               return -ENODEV;
 
        input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_ABS);
 
@@ -2468,10 +2826,15 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
        /* kept for making udev and libwacom accepting the pad */
        __set_bit(BTN_STYLUS, input_dev->keybit);
 
+       wacom_setup_numbered_buttons(input_dev, features->numbered_buttons);
+
        switch (features->type) {
+
+       case CINTIQ_HYBRID:
+       case CINTIQ_COMPANION_2:
+       case DTK:
+       case DTUS:
        case GRAPHIRE_BT:
-               __set_bit(BTN_0, input_dev->keybit);
-               __set_bit(BTN_1, input_dev->keybit);
                break;
 
        case WACOM_MO:
@@ -2489,16 +2852,6 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
                break;
 
        case WACOM_24HD:
-               __set_bit(BTN_A, input_dev->keybit);
-               __set_bit(BTN_B, input_dev->keybit);
-               __set_bit(BTN_C, input_dev->keybit);
-               __set_bit(BTN_X, input_dev->keybit);
-               __set_bit(BTN_Y, input_dev->keybit);
-               __set_bit(BTN_Z, input_dev->keybit);
-
-               for (i = 0; i < 10; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                __set_bit(KEY_PROG1, input_dev->keybit);
                __set_bit(KEY_PROG2, input_dev->keybit);
                __set_bit(KEY_PROG3, input_dev->keybit);
@@ -2520,12 +2873,6 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
                __set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit);
                break;
 
-       case DTK:
-               for (i = 0; i < 6; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
-               break;
-
        case WACOM_22HD:
                __set_bit(KEY_PROG1, input_dev->keybit);
                __set_bit(KEY_PROG2, input_dev->keybit);
@@ -2533,52 +2880,22 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
                /* fall through */
 
        case WACOM_21UX2:
-               __set_bit(BTN_A, input_dev->keybit);
-               __set_bit(BTN_B, input_dev->keybit);
-               __set_bit(BTN_C, input_dev->keybit);
-               __set_bit(BTN_X, input_dev->keybit);
-               __set_bit(BTN_Y, input_dev->keybit);
-               __set_bit(BTN_Z, input_dev->keybit);
-               __set_bit(BTN_BASE, input_dev->keybit);
-               __set_bit(BTN_BASE2, input_dev->keybit);
-               /* fall through */
-
        case WACOM_BEE:
-               __set_bit(BTN_8, input_dev->keybit);
-               __set_bit(BTN_9, input_dev->keybit);
-               /* fall through */
-
        case CINTIQ:
-               for (i = 0; i < 8; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
                input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
                break;
 
        case WACOM_13HD:
-               for (i = 0; i < 9; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
                break;
 
        case INTUOS3:
        case INTUOS3L:
-               __set_bit(BTN_4, input_dev->keybit);
-               __set_bit(BTN_5, input_dev->keybit);
-               __set_bit(BTN_6, input_dev->keybit);
-               __set_bit(BTN_7, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
                /* fall through */
 
        case INTUOS3S:
-               __set_bit(BTN_0, input_dev->keybit);
-               __set_bit(BTN_1, input_dev->keybit);
-               __set_bit(BTN_2, input_dev->keybit);
-               __set_bit(BTN_3, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
                break;
 
@@ -2586,19 +2903,8 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
        case INTUOS5L:
        case INTUOSPM:
        case INTUOSPL:
-               __set_bit(BTN_7, input_dev->keybit);
-               __set_bit(BTN_8, input_dev->keybit);
-               /* fall through */
-
        case INTUOS5S:
        case INTUOSPS:
-               /* touch interface does not have the pad device */
-               if (features->device_type != BTN_TOOL_PEN)
-                       return -ENODEV;
-
-               for (i = 0; i < 7; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
                break;
 
@@ -2613,36 +2919,14 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
 
        case INTUOS4:
        case INTUOS4L:
-               __set_bit(BTN_7, input_dev->keybit);
-               __set_bit(BTN_8, input_dev->keybit);
-               /* fall through */
-
        case INTUOS4S:
-               for (i = 0; i < 7; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
                input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
                break;
 
-       case CINTIQ_HYBRID:
-               for (i = 0; i < 9; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-
-               break;
-
-       case DTUS:
-               for (i = 0; i < 4; i++)
-                       __set_bit(BTN_0 + i, input_dev->keybit);
-               break;
-
        case INTUOSHT:
        case BAMBOO_PT:
-               /* pad device is on the touch interface */
-               if ((features->device_type != BTN_TOOL_FINGER) ||
-                   /* Bamboo Pen only tablet does not have pad */
-                   ((features->type == BAMBOO_PT) && !features->touch_max))
-                       return -ENODEV;
-
+       case BAMBOO_TOUCH:
+       case INTUOSHT2:
                __clear_bit(ABS_MISC, input_dev->absbit);
 
                __set_bit(BTN_LEFT, input_dev->keybit);
@@ -2652,6 +2936,11 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
 
                break;
 
+       case REMOTE:
+               input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
+               input_set_abs_params(input_dev, ABS_WHEEL, 0, 71, 0, 0);
+               break;
+
        default:
                /* no pad supported */
                return -ENODEV;
@@ -2667,7 +2956,7 @@ static const struct wacom_features wacom_features_0x10 =
          GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
 static const struct wacom_features wacom_features_0x81 =
        { "Wacom Graphire BT", 16704, 12064, 511, 32,
-         GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+         GRAPHIRE_BT, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES, 2 };
 static const struct wacom_features wacom_features_0x11 =
        { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
          GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
@@ -2793,77 +3082,77 @@ static const struct wacom_features wacom_features_0x45 =
          INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xB0 =
        { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
-         INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
 static const struct wacom_features wacom_features_0xB1 =
        { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
-         INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB2 =
        { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
-         INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB3 =
        { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
-         INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB4 =
        { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
-         INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB5 =
        { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
-         INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xB7 =
        { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
-         INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 4 };
 static const struct wacom_features wacom_features_0xB8 =
        { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
-         INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
 static const struct wacom_features wacom_features_0xB9 =
        { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
-         INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0xBA =
        { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
-         INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0xBB =
        { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
-         INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0xBC =
        { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
-         INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0xBD =
        { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
-         INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS4WL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0x26 =
        { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
-         INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
+         INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16 };
 static const struct wacom_features wacom_features_0x27 =
        { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
-         INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
+         INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
 static const struct wacom_features wacom_features_0x28 =
        { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
-         INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
+         INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16 };
 static const struct wacom_features wacom_features_0x29 =
        { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
-         INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7 };
 static const struct wacom_features wacom_features_0x2A =
        { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
-         INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9 };
 static const struct wacom_features wacom_features_0x314 =
        { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
-         INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
+         INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 7, .touch_max = 16,
          .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
 static const struct wacom_features wacom_features_0x315 =
        { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
-         INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
+         INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
          .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
 static const struct wacom_features wacom_features_0x317 =
        { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
-         INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
+         INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 16,
          .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
 static const struct wacom_features wacom_features_0xF4 =
        { "Wacom Cintiq 24HD", 104080, 65200, 2047, 63,
-         WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0xF8 =
        { "Wacom Cintiq 24HD touch", 104080, 65200, 2047, 63, /* Pen */
-         WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 16,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
 static const struct wacom_features wacom_features_0xF6 =
@@ -2872,11 +3161,11 @@ static const struct wacom_features wacom_features_0xF6 =
          .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
 static const struct wacom_features wacom_features_0x32A =
        { "Wacom Cintiq 27QHD", 119740, 67520, 2047, 63,
-         WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x32B =
        { "Wacom Cintiq 27QHD touch", 119740, 67520, 2047, 63,
-         WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         WACOM_27QHD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 0,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32C };
 static const struct wacom_features wacom_features_0x32C =
@@ -2884,20 +3173,20 @@ static const struct wacom_features wacom_features_0x32C =
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x32B, .touch_max = 10 };
 static const struct wacom_features wacom_features_0x3F =
        { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
-         CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 8 };
 static const struct wacom_features wacom_features_0xC5 =
        { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
-         WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
 static const struct wacom_features wacom_features_0xC6 =
        { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
-         WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+         WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 10 };
 static const struct wacom_features wacom_features_0x304 =
        { "Wacom Cintiq 13HD", 59152, 33448, 1023, 63,
-         WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x333 =
        { "Wacom Cintiq 13HD touch", 59152, 33448, 2047, 63,
-         WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x335 };
 static const struct wacom_features wacom_features_0x335 =
@@ -2916,19 +3205,23 @@ static const struct wacom_features wacom_features_0xF0 =
          DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xFB =
        { "Wacom DTU1031", 21896, 13760, 511, 0,
-         DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+         DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
          WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x32F =
        { "Wacom DTU1031X", 22472, 12728, 511, 0,
-         DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+         DTUSX, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 0,
+         WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
+static const struct wacom_features wacom_features_0x336 =
+       { "Wacom DTU1141", 23472, 13203, 1023, 0,
+         DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 4,
          WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x57 =
        { "Wacom DTK2241", 95640, 54060, 2047, 63,
-         DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x59 = /* Pen */
        { "Wacom DTH2242", 95640, 54060, 2047, 63,
-         DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 6,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
 static const struct wacom_features wacom_features_0x5D = /* Touch */
@@ -2937,15 +3230,15 @@ static const struct wacom_features wacom_features_0x5D = /* Touch */
          .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
 static const struct wacom_features wacom_features_0xCC =
        { "Wacom Cintiq 21UX2", 86800, 65200, 2047, 63,
-         WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0xFA =
        { "Wacom Cintiq 22HD", 95440, 53860, 2047, 63,
-         WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET };
 static const struct wacom_features wacom_features_0x5B =
        { "Wacom Cintiq 22HDT", 95440, 53860, 2047, 63,
-         WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 18,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
 static const struct wacom_features wacom_features_0x5E =
@@ -3025,11 +3318,10 @@ static const struct wacom_features wacom_features_0x47 =
        { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
          INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x84 =
-       { "Wacom Wireless Receiver", 0, 0, 0, 0,
-         WIRELESS, 0, 0, .touch_max = 16 };
+       { "Wacom Wireless Receiver", .type = WIRELESS, .touch_max = 16 };
 static const struct wacom_features wacom_features_0xD0 =
        { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
-         BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
+         BAMBOO_TOUCH, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
 static const struct wacom_features wacom_features_0xD1 =
        { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
          BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
@@ -3041,10 +3333,10 @@ static const struct wacom_features wacom_features_0xD3 =
          BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
 static const struct wacom_features wacom_features_0xD4 =
        { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
-         BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+         BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xD5 =
        { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
-         BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+         BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0xD6 =
        { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
          BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
@@ -3071,7 +3363,7 @@ static const struct wacom_features wacom_features_0xDF =
          BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
 static const struct wacom_features wacom_features_0x300 =
        { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
-         BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+         BAMBOO_PEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x301 =
        { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
          BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -3092,7 +3384,7 @@ static const struct wacom_features wacom_features_0x6004 =
          TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x307 =
        { "Wacom ISDv5 307", 59152, 33448, 2047, 63,
-         CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
 static const struct wacom_features wacom_features_0x309 =
@@ -3101,7 +3393,7 @@ static const struct wacom_features wacom_features_0x309 =
          .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
 static const struct wacom_features wacom_features_0x30A =
        { "Wacom ISDv5 30A", 59152, 33448, 2047, 63,
-         CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+         CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9,
          WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x30C };
 static const struct wacom_features wacom_features_0x30C =
@@ -3114,10 +3406,38 @@ static const struct wacom_features wacom_features_0x318 =
 static const struct wacom_features wacom_features_0x319 =
        { "Wacom Wireless Bamboo PAD", 4095, 4095, /* Touch */
          .type = BAMBOO_PAD, 35, 48, .touch_max = 4 };
+static const struct wacom_features wacom_features_0x325 =
+       { "Wacom ISDv5 325", 59552, 33848, 2047, 63,
+         CINTIQ_COMPANION_2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 11,
+         WACOM_CINTIQ_OFFSET, WACOM_CINTIQ_OFFSET,
+         .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x326 };
+static const struct wacom_features wacom_features_0x326 = /* Touch */
+       { "Wacom ISDv5 326", .type = HID_GENERIC, .oVid = USB_VENDOR_ID_WACOM,
+         .oPid = 0x325 };
 static const struct wacom_features wacom_features_0x323 =
        { "Wacom Intuos P M", 21600, 13500, 1023, 31,
          INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
          .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
+static const struct wacom_features wacom_features_0x331 =
+       { "Wacom Express Key Remote", .type = REMOTE,
+         .numbered_buttons = 18, .check_for_hid_type = true,
+         .hid_type = HID_TYPE_USBNONE };
+static const struct wacom_features wacom_features_0x33B =
+       { "Wacom Intuos S 2", 15200, 9500, 2047, 63,
+         INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+         .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
+static const struct wacom_features wacom_features_0x33C =
+       { "Wacom Intuos PT S 2", 15200, 9500, 2047, 63,
+         INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
+         .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
+static const struct wacom_features wacom_features_0x33D =
+       { "Wacom Intuos P M 2", 21600, 13500, 2047, 63,
+         INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+         .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
+static const struct wacom_features wacom_features_0x33E =
+       { "Wacom Intuos PT M 2", 21600, 13500, 2047, 63,
+         INTUOSHT2, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
+         .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
 
 static const struct wacom_features wacom_features_HID_ANY_ID =
        { "Wacom HID", .type = HID_GENERIC };
@@ -3269,12 +3589,20 @@ const struct hid_device_id wacom_ids[] = {
        { USB_DEVICE_WACOM(0x318) },
        { USB_DEVICE_WACOM(0x319) },
        { USB_DEVICE_WACOM(0x323) },
+       { USB_DEVICE_WACOM(0x325) },
+       { USB_DEVICE_WACOM(0x326) },
        { USB_DEVICE_WACOM(0x32A) },
        { USB_DEVICE_WACOM(0x32B) },
        { USB_DEVICE_WACOM(0x32C) },
        { USB_DEVICE_WACOM(0x32F) },
+       { USB_DEVICE_WACOM(0x331) },
        { USB_DEVICE_WACOM(0x333) },
        { USB_DEVICE_WACOM(0x335) },
+       { USB_DEVICE_WACOM(0x336) },
+       { USB_DEVICE_WACOM(0x33B) },
+       { USB_DEVICE_WACOM(0x33C) },
+       { USB_DEVICE_WACOM(0x33D) },
+       { USB_DEVICE_WACOM(0x33E) },
        { USB_DEVICE_WACOM(0x4001) },
        { USB_DEVICE_WACOM(0x4004) },
        { USB_DEVICE_WACOM(0x5000) },