Merge tag 'for-f2fs-3.16' of git://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk...
[firefly-linux-kernel-4.4.55.git] / drivers / input / tablet / wacom_wac.c
index 4822c57a3756f4e3175fac3e1def90611028eb6d..977d05cd9e2ea707c08c5eb6d3c9a4fd1a07adae 100644 (file)
@@ -484,6 +484,8 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
                input_report_key(input, BTN_TOUCH, 0);
                input_report_abs(input, ABS_PRESSURE, 0);
                input_report_abs(input, ABS_DISTANCE, wacom->features.distance_max);
+               if (features->quirks & WACOM_QUIRK_MULTI_INPUT)
+                       wacom->shared->stylus_in_proximity = true;
        }
 
        /* Exit report */
@@ -928,12 +930,12 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
                input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
 
                if (touch) {
-                       int t_x = le16_to_cpup((__le16 *)&data[offset + 2]);
-                       int c_x = le16_to_cpup((__le16 *)&data[offset + 4]);
-                       int t_y = le16_to_cpup((__le16 *)&data[offset + 6]);
-                       int c_y = le16_to_cpup((__le16 *)&data[offset + 8]);
-                       int w = le16_to_cpup((__le16 *)&data[offset + 10]);
-                       int h = le16_to_cpup((__le16 *)&data[offset + 12]);
+                       int t_x = get_unaligned_le16(&data[offset + 2]);
+                       int c_x = get_unaligned_le16(&data[offset + 4]);
+                       int t_y = get_unaligned_le16(&data[offset + 6]);
+                       int c_y = get_unaligned_le16(&data[offset + 8]);
+                       int w = get_unaligned_le16(&data[offset + 10]);
+                       int h = get_unaligned_le16(&data[offset + 12]);
 
                        input_report_abs(input, ABS_MT_POSITION_X, t_x);
                        input_report_abs(input, ABS_MT_POSITION_Y, t_y);
@@ -962,7 +964,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
        int x_offset = 0;
 
        /* MTTPC does not support Height and Width */
-       if (wacom->features.type == MTTPC)
+       if (wacom->features.type == MTTPC || wacom->features.type == MTTPC_B)
                x_offset = -4;
 
        /*
@@ -978,7 +980,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
        for (i = 0; i < contacts_to_send; i++) {
                int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset) * i + 3;
                bool touch = data[offset] & 0x1;
-               int id = le16_to_cpup((__le16 *)&data[offset + 1]);
+               int id = get_unaligned_le16(&data[offset + 1]);
                int slot = input_mt_get_slot_by_key(input, id);
 
                if (slot < 0)
@@ -987,8 +989,8 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
                input_mt_slot(input, slot);
                input_mt_report_slot_state(input, MT_TOOL_FINGER, touch);
                if (touch) {
-                       int x = le16_to_cpup((__le16 *)&data[offset + x_offset + 7]);
-                       int y = le16_to_cpup((__le16 *)&data[offset + x_offset + 9]);
+                       int x = get_unaligned_le16(&data[offset + x_offset + 7]);
+                       int y = get_unaligned_le16(&data[offset + x_offset + 9]);
                        input_report_abs(input, ABS_MT_POSITION_X, x);
                        input_report_abs(input, ABS_MT_POSITION_Y, y);
                }
@@ -1047,6 +1049,10 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
                        prox = data[0] & 0x01;
                        x = get_unaligned_le16(&data[1]);
                        y = get_unaligned_le16(&data[3]);
+               } else if (len == WACOM_PKGLEN_TPC1FG_B) {
+                       prox = data[2] & 0x01;
+                       x = get_unaligned_le16(&data[3]);
+                       y = get_unaligned_le16(&data[5]);
                } else {
                        prox = data[1] & 0x01;
                        x = le16_to_cpup((__le16 *)&data[2]);
@@ -1110,6 +1116,9 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
        case WACOM_PKGLEN_TPC2FG:
                return wacom_tpc_mt_touch(wacom);
 
+       case WACOM_PKGLEN_PENABLED:
+               return wacom_tpc_pen(wacom);
+
        default:
                switch (data[0]) {
                case WACOM_REPORT_TPC1FG:
@@ -1119,6 +1128,7 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
                        return wacom_tpc_single_touch(wacom, len);
 
                case WACOM_REPORT_TPCMT:
+               case WACOM_REPORT_TPCMT2:
                        return wacom_mt_touch(wacom);
 
                case WACOM_REPORT_PENABLED:
@@ -1461,6 +1471,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
        case TABLETPC2FG:
        case MTSCREEN:
        case MTTPC:
+       case MTTPC_B:
                sync = wacom_tpc_irq(wacom_wac, len);
                break;
 
@@ -1565,10 +1576,10 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,
        struct wacom_features *features = &wacom_wac->features;
 
        if (features->device_type == BTN_TOOL_PEN) {
-               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_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);
 
@@ -1802,6 +1813,7 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
 
        case MTSCREEN:
        case MTTPC:
+       case MTTPC_B:
        case TABLETPC2FG:
                if (features->device_type == BTN_TOOL_FINGER) {
                        unsigned int flags = INPUT_MT_DIRECT;
@@ -2123,11 +2135,11 @@ static const struct wacom_features wacom_features_0x317 =
          63, INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
          .touch_max = 16 };
 static const struct wacom_features wacom_features_0xF4 =
-       { "Wacom Cintiq 24HD",       WACOM_PKGLEN_INTUOS,   104480, 65600, 2047,
-         63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+       { "Wacom Cintiq 24HD",       WACOM_PKGLEN_INTUOS,   104280, 65400, 2047,
+         63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0xF8 =
-       { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS,   104480, 65600, 2047, /* Pen */
-         63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+       { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS,   104280, 65400, 2047, /* Pen */
+         63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
 static const struct wacom_features wacom_features_0xF6 =
        { "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
@@ -2142,8 +2154,8 @@ static const struct wacom_features wacom_features_0xC6 =
        { "Wacom Cintiq 12WX",    WACOM_PKGLEN_INTUOS,    53020, 33440, 1023,
          63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
 static const struct wacom_features wacom_features_0x304 =
-       { "Wacom Cintiq 13HD",    WACOM_PKGLEN_INTUOS,    59552, 33848, 1023,
-         63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+       { "Wacom Cintiq 13HD",    WACOM_PKGLEN_INTUOS,    59352, 33648, 1023,
+         63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0xC7 =
        { "Wacom DTU1931",        WACOM_PKGLEN_GRAPHIRE,  37832, 30305,  511,
          0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -2157,24 +2169,24 @@ static const struct wacom_features wacom_features_0xFB =
        { "Wacom DTU1031",        WACOM_PKGLEN_DTUS,      22096, 13960,  511,
          0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x57 =
-       { "Wacom DTK2241",        WACOM_PKGLEN_INTUOS,    95840, 54260, 2047,
-         63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES};
+       { "Wacom DTK2241",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047,
+         63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0x59 = /* Pen */
-       { "Wacom DTH2242",        WACOM_PKGLEN_INTUOS,    95840, 54260, 2047,
-         63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+       { "Wacom DTH2242",        WACOM_PKGLEN_INTUOS,    95640, 54060, 2047,
+         63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
 static const struct wacom_features wacom_features_0x5D = /* Touch */
        { "Wacom DTH2242",       .type = WACOM_24HDT,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10 };
 static const struct wacom_features wacom_features_0xCC =
-       { "Wacom Cintiq 21UX2",   WACOM_PKGLEN_INTUOS,    87200, 65600, 2047,
-         63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+       { "Wacom Cintiq 21UX2",   WACOM_PKGLEN_INTUOS,    87000, 65400, 2047,
+         63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0xFA =
-       { "Wacom Cintiq 22HD",    WACOM_PKGLEN_INTUOS,    95840, 54260, 2047,
-         63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+       { "Wacom Cintiq 22HD",    WACOM_PKGLEN_INTUOS,    95640, 54060, 2047,
+         63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
 static const struct wacom_features wacom_features_0x5B =
-       { "Wacom Cintiq 22HDT", WACOM_PKGLEN_INTUOS,      95840, 54260, 2047,
-         63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+       { "Wacom Cintiq 22HDT", WACOM_PKGLEN_INTUOS,      95640, 54060, 2047,
+         63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
 static const struct wacom_features wacom_features_0x5E =
        { "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
@@ -2233,9 +2245,21 @@ static const struct wacom_features wacom_features_0x10E =
 static const struct wacom_features wacom_features_0x10F =
        { "Wacom ISDv4 10F",      WACOM_PKGLEN_MTTPC,     27760, 15694,  255,
          0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+static const struct wacom_features wacom_features_0x116 =
+       { "Wacom ISDv4 116",      WACOM_PKGLEN_GRAPHIRE,  26202, 16325,  255,
+         0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x4001 =
        { "Wacom ISDv4 4001",      WACOM_PKGLEN_MTTPC,     26202, 16325,  255,
          0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+static const struct wacom_features wacom_features_0x4004 =
+       { "Wacom ISDv4 4004",      WACOM_PKGLEN_MTTPC,     11060, 6220,  255,
+         0, MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+static const struct wacom_features wacom_features_0x5000 =
+       { "Wacom ISDv4 5000",      WACOM_PKGLEN_MTTPC,     27848, 15752,  1023,
+         0, MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+static const struct wacom_features wacom_features_0x5002 =
+       { "Wacom ISDv4 5002",      WACOM_PKGLEN_MTTPC,     29576, 16724,  1023,
+         0, MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x47 =
        { "Wacom Intuos2 6x8",    WACOM_PKGLEN_INTUOS,    20320, 16240, 1023,
          31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -2316,8 +2340,8 @@ static const struct wacom_features wacom_features_0x6004 =
        { "ISD-V4",               WACOM_PKGLEN_GRAPHIRE,  12800,  8000,  255,
          0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
 static const struct wacom_features wacom_features_0x0307 =
-       { "Wacom ISDv5 307", WACOM_PKGLEN_INTUOS,  59552,  33848, 2047,
-         63, CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
+       { "Wacom ISDv5 307", WACOM_PKGLEN_INTUOS,  59352,  33648, 2047,
+         63, CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
          .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
 static const struct wacom_features wacom_features_0x0309 =
        { "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
@@ -2447,6 +2471,7 @@ const struct usb_device_id wacom_ids[] = {
        { USB_DEVICE_WACOM(0x10D) },
        { USB_DEVICE_WACOM(0x10E) },
        { USB_DEVICE_WACOM(0x10F) },
+       { USB_DEVICE_WACOM(0x116) },
        { USB_DEVICE_WACOM(0x300) },
        { USB_DEVICE_WACOM(0x301) },
        { USB_DEVICE_DETAILED(0x302, USB_CLASS_HID, 0, 0) },
@@ -2457,6 +2482,9 @@ const struct usb_device_id wacom_ids[] = {
        { USB_DEVICE_DETAILED(0x315, USB_CLASS_HID, 0, 0) },
        { USB_DEVICE_DETAILED(0x317, USB_CLASS_HID, 0, 0) },
        { USB_DEVICE_WACOM(0x4001) },
+       { USB_DEVICE_WACOM(0x4004) },
+       { USB_DEVICE_WACOM(0x5000) },
+       { USB_DEVICE_WACOM(0x5002) },
        { USB_DEVICE_WACOM(0x47) },
        { USB_DEVICE_WACOM(0xF4) },
        { USB_DEVICE_WACOM(0xF8) },