diff options
Diffstat (limited to 'drivers/input')
| -rw-r--r-- | drivers/input/keyboard/adp5588-keys.c | 3 | ||||
| -rw-r--r-- | drivers/input/keyboard/adp5589-keys.c | 3 | ||||
| -rw-r--r-- | drivers/input/keyboard/bf54x-keys.c | 3 | ||||
| -rw-r--r-- | drivers/input/misc/adxl34x.c | 2 | ||||
| -rw-r--r-- | drivers/input/misc/hp_sdc_rtc.c | 5 | ||||
| -rw-r--r-- | drivers/input/misc/pcf8574_keypad.c | 7 | ||||
| -rw-r--r-- | drivers/input/mouse/alps.c | 206 | ||||
| -rw-r--r-- | drivers/input/mouse/alps.h | 1 | ||||
| -rw-r--r-- | drivers/input/mouse/elantech.c | 1 | ||||
| -rw-r--r-- | drivers/input/serio/serio.c | 24 | ||||
| -rw-r--r-- | drivers/input/touchscreen/Kconfig | 11 | ||||
| -rw-r--r-- | drivers/input/touchscreen/Makefile | 1 | ||||
| -rw-r--r-- | drivers/input/touchscreen/atmel-wm97xx.c | 2 | ||||
| -rw-r--r-- | drivers/input/touchscreen/cyttsp4_core.c | 3 | ||||
| -rw-r--r-- | drivers/input/touchscreen/sur40.c | 466 | ||||
| -rw-r--r-- | drivers/input/touchscreen/usbtouchscreen.c | 22 |
16 files changed, 736 insertions, 24 deletions
diff --git a/drivers/input/keyboard/adp5588-keys.c b/drivers/input/keyboard/adp5588-keys.c index dbd2047f1641..3ed23513d881 100644 --- a/drivers/input/keyboard/adp5588-keys.c +++ b/drivers/input/keyboard/adp5588-keys.c | |||
| @@ -536,7 +536,8 @@ static int adp5588_probe(struct i2c_client *client, | |||
| 536 | __set_bit(EV_REP, input->evbit); | 536 | __set_bit(EV_REP, input->evbit); |
| 537 | 537 | ||
| 538 | for (i = 0; i < input->keycodemax; i++) | 538 | for (i = 0; i < input->keycodemax; i++) |
| 539 | __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit); | 539 | if (kpad->keycode[i] <= KEY_MAX) |
| 540 | __set_bit(kpad->keycode[i], input->keybit); | ||
| 540 | __clear_bit(KEY_RESERVED, input->keybit); | 541 | __clear_bit(KEY_RESERVED, input->keybit); |
| 541 | 542 | ||
| 542 | if (kpad->gpimapsize) | 543 | if (kpad->gpimapsize) |
diff --git a/drivers/input/keyboard/adp5589-keys.c b/drivers/input/keyboard/adp5589-keys.c index 67d12b3427c9..60dafd4fa692 100644 --- a/drivers/input/keyboard/adp5589-keys.c +++ b/drivers/input/keyboard/adp5589-keys.c | |||
| @@ -992,7 +992,8 @@ static int adp5589_probe(struct i2c_client *client, | |||
| 992 | __set_bit(EV_REP, input->evbit); | 992 | __set_bit(EV_REP, input->evbit); |
| 993 | 993 | ||
| 994 | for (i = 0; i < input->keycodemax; i++) | 994 | for (i = 0; i < input->keycodemax; i++) |
| 995 | __set_bit(kpad->keycode[i] & KEY_MAX, input->keybit); | 995 | if (kpad->keycode[i] <= KEY_MAX) |
| 996 | __set_bit(kpad->keycode[i], input->keybit); | ||
| 996 | __clear_bit(KEY_RESERVED, input->keybit); | 997 | __clear_bit(KEY_RESERVED, input->keybit); |
| 997 | 998 | ||
| 998 | if (kpad->gpimapsize) | 999 | if (kpad->gpimapsize) |
diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c index fc88fb48d70d..09b91d093087 100644 --- a/drivers/input/keyboard/bf54x-keys.c +++ b/drivers/input/keyboard/bf54x-keys.c | |||
| @@ -289,7 +289,8 @@ static int bfin_kpad_probe(struct platform_device *pdev) | |||
| 289 | __set_bit(EV_REP, input->evbit); | 289 | __set_bit(EV_REP, input->evbit); |
| 290 | 290 | ||
| 291 | for (i = 0; i < input->keycodemax; i++) | 291 | for (i = 0; i < input->keycodemax; i++) |
| 292 | __set_bit(bf54x_kpad->keycode[i] & KEY_MAX, input->keybit); | 292 | if (bf54x_kpad->keycode[i] <= KEY_MAX) |
| 293 | __set_bit(bf54x_kpad->keycode[i], input->keybit); | ||
| 293 | __clear_bit(KEY_RESERVED, input->keybit); | 294 | __clear_bit(KEY_RESERVED, input->keybit); |
| 294 | 295 | ||
| 295 | error = input_register_device(input); | 296 | error = input_register_device(input); |
diff --git a/drivers/input/misc/adxl34x.c b/drivers/input/misc/adxl34x.c index 0735de3a6468..1cb1da294419 100644 --- a/drivers/input/misc/adxl34x.c +++ b/drivers/input/misc/adxl34x.c | |||
| @@ -158,7 +158,7 @@ | |||
| 158 | 158 | ||
| 159 | /* ORIENT ADXL346 only */ | 159 | /* ORIENT ADXL346 only */ |
| 160 | #define ADXL346_2D_VALID (1 << 6) | 160 | #define ADXL346_2D_VALID (1 << 6) |
| 161 | #define ADXL346_2D_ORIENT(x) (((x) & 0x3) >> 4) | 161 | #define ADXL346_2D_ORIENT(x) (((x) & 0x30) >> 4) |
| 162 | #define ADXL346_3D_VALID (1 << 3) | 162 | #define ADXL346_3D_VALID (1 << 3) |
| 163 | #define ADXL346_3D_ORIENT(x) ((x) & 0x7) | 163 | #define ADXL346_3D_ORIENT(x) ((x) & 0x7) |
| 164 | #define ADXL346_2D_PORTRAIT_POS 0 /* +X */ | 164 | #define ADXL346_2D_PORTRAIT_POS 0 /* +X */ |
diff --git a/drivers/input/misc/hp_sdc_rtc.c b/drivers/input/misc/hp_sdc_rtc.c index 86b822806e95..45e0e3e55de2 100644 --- a/drivers/input/misc/hp_sdc_rtc.c +++ b/drivers/input/misc/hp_sdc_rtc.c | |||
| @@ -180,7 +180,10 @@ static int64_t hp_sdc_rtc_read_i8042timer (uint8_t loadcmd, int numreg) | |||
| 180 | if (WARN_ON(down_interruptible(&i8042tregs))) | 180 | if (WARN_ON(down_interruptible(&i8042tregs))) |
| 181 | return -1; | 181 | return -1; |
| 182 | 182 | ||
| 183 | if (hp_sdc_enqueue_transaction(&t)) return -1; | 183 | if (hp_sdc_enqueue_transaction(&t)) { |
| 184 | up(&i8042tregs); | ||
| 185 | return -1; | ||
| 186 | } | ||
| 184 | 187 | ||
| 185 | /* Sleep until results come back. */ | 188 | /* Sleep until results come back. */ |
| 186 | if (WARN_ON(down_interruptible(&i8042tregs))) | 189 | if (WARN_ON(down_interruptible(&i8042tregs))) |
diff --git a/drivers/input/misc/pcf8574_keypad.c b/drivers/input/misc/pcf8574_keypad.c index e37392976fdd..0deca5a3c87f 100644 --- a/drivers/input/misc/pcf8574_keypad.c +++ b/drivers/input/misc/pcf8574_keypad.c | |||
| @@ -113,9 +113,12 @@ static int pcf8574_kp_probe(struct i2c_client *client, const struct i2c_device_i | |||
| 113 | idev->keycodemax = ARRAY_SIZE(lp->btncode); | 113 | idev->keycodemax = ARRAY_SIZE(lp->btncode); |
| 114 | 114 | ||
| 115 | for (i = 0; i < ARRAY_SIZE(pcf8574_kp_btncode); i++) { | 115 | for (i = 0; i < ARRAY_SIZE(pcf8574_kp_btncode); i++) { |
| 116 | lp->btncode[i] = pcf8574_kp_btncode[i]; | 116 | if (lp->btncode[i] <= KEY_MAX) { |
| 117 | __set_bit(lp->btncode[i] & KEY_MAX, idev->keybit); | 117 | lp->btncode[i] = pcf8574_kp_btncode[i]; |
| 118 | __set_bit(lp->btncode[i], idev->keybit); | ||
| 119 | } | ||
| 118 | } | 120 | } |
| 121 | __clear_bit(KEY_RESERVED, idev->keybit); | ||
| 119 | 122 | ||
| 120 | sprintf(lp->name, DRV_NAME); | 123 | sprintf(lp->name, DRV_NAME); |
| 121 | sprintf(lp->phys, "kp_data/input0"); | 124 | sprintf(lp->phys, "kp_data/input0"); |
diff --git a/drivers/input/mouse/alps.c b/drivers/input/mouse/alps.c index ca7a26f1dce8..5cf62e315218 100644 --- a/drivers/input/mouse/alps.c +++ b/drivers/input/mouse/alps.c | |||
| @@ -70,6 +70,25 @@ static const struct alps_nibble_commands alps_v4_nibble_commands[] = { | |||
| 70 | { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */ | 70 | { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */ |
| 71 | }; | 71 | }; |
| 72 | 72 | ||
| 73 | static const struct alps_nibble_commands alps_v6_nibble_commands[] = { | ||
| 74 | { PSMOUSE_CMD_ENABLE, 0x00 }, /* 0 */ | ||
| 75 | { PSMOUSE_CMD_SETRATE, 0x0a }, /* 1 */ | ||
| 76 | { PSMOUSE_CMD_SETRATE, 0x14 }, /* 2 */ | ||
| 77 | { PSMOUSE_CMD_SETRATE, 0x28 }, /* 3 */ | ||
| 78 | { PSMOUSE_CMD_SETRATE, 0x3c }, /* 4 */ | ||
| 79 | { PSMOUSE_CMD_SETRATE, 0x50 }, /* 5 */ | ||
| 80 | { PSMOUSE_CMD_SETRATE, 0x64 }, /* 6 */ | ||
| 81 | { PSMOUSE_CMD_SETRATE, 0xc8 }, /* 7 */ | ||
| 82 | { PSMOUSE_CMD_GETID, 0x00 }, /* 8 */ | ||
| 83 | { PSMOUSE_CMD_GETINFO, 0x00 }, /* 9 */ | ||
| 84 | { PSMOUSE_CMD_SETRES, 0x00 }, /* a */ | ||
| 85 | { PSMOUSE_CMD_SETRES, 0x01 }, /* b */ | ||
| 86 | { PSMOUSE_CMD_SETRES, 0x02 }, /* c */ | ||
| 87 | { PSMOUSE_CMD_SETRES, 0x03 }, /* d */ | ||
| 88 | { PSMOUSE_CMD_SETSCALE21, 0x00 }, /* e */ | ||
| 89 | { PSMOUSE_CMD_SETSCALE11, 0x00 }, /* f */ | ||
| 90 | }; | ||
| 91 | |||
| 73 | 92 | ||
| 74 | #define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */ | 93 | #define ALPS_DUALPOINT 0x02 /* touchpad has trackstick */ |
| 75 | #define ALPS_PASS 0x04 /* device has a pass-through port */ | 94 | #define ALPS_PASS 0x04 /* device has a pass-through port */ |
| @@ -103,6 +122,7 @@ static const struct alps_model_info alps_model_data[] = { | |||
| 103 | /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ | 122 | /* Dell Latitude E5500, E6400, E6500, Precision M4400 */ |
| 104 | { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, | 123 | { { 0x62, 0x02, 0x14 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, |
| 105 | ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, | 124 | ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, |
| 125 | { { 0x73, 0x00, 0x14 }, 0x00, ALPS_PROTO_V6, 0xff, 0xff, ALPS_DUALPOINT }, /* Dell XT2 */ | ||
| 106 | { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ | 126 | { { 0x73, 0x02, 0x50 }, 0x00, ALPS_PROTO_V2, 0xcf, 0xcf, ALPS_FOUR_BUTTONS }, /* Dell Vostro 1400 */ |
| 107 | { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, | 127 | { { 0x52, 0x01, 0x14 }, 0x00, ALPS_PROTO_V2, 0xff, 0xff, |
| 108 | ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */ | 128 | ALPS_PASS | ALPS_DUALPOINT | ALPS_PS2_INTERLEAVED }, /* Toshiba Tecra A11-11L */ |
| @@ -645,6 +665,76 @@ static void alps_process_packet_v3(struct psmouse *psmouse) | |||
| 645 | alps_process_touchpad_packet_v3(psmouse); | 665 | alps_process_touchpad_packet_v3(psmouse); |
| 646 | } | 666 | } |
| 647 | 667 | ||
| 668 | static void alps_process_packet_v6(struct psmouse *psmouse) | ||
| 669 | { | ||
| 670 | struct alps_data *priv = psmouse->private; | ||
| 671 | unsigned char *packet = psmouse->packet; | ||
| 672 | struct input_dev *dev = psmouse->dev; | ||
| 673 | struct input_dev *dev2 = priv->dev2; | ||
| 674 | int x, y, z, left, right, middle; | ||
| 675 | |||
| 676 | /* | ||
| 677 | * We can use Byte5 to distinguish if the packet is from Touchpad | ||
| 678 | * or Trackpoint. | ||
| 679 | * Touchpad: 0 - 0x7E | ||
| 680 | * Trackpoint: 0x7F | ||
| 681 | */ | ||
| 682 | if (packet[5] == 0x7F) { | ||
| 683 | /* It should be a DualPoint when received Trackpoint packet */ | ||
| 684 | if (!(priv->flags & ALPS_DUALPOINT)) | ||
| 685 | return; | ||
| 686 | |||
| 687 | /* Trackpoint packet */ | ||
| 688 | x = packet[1] | ((packet[3] & 0x20) << 2); | ||
| 689 | y = packet[2] | ((packet[3] & 0x40) << 1); | ||
| 690 | z = packet[4]; | ||
| 691 | left = packet[3] & 0x01; | ||
| 692 | right = packet[3] & 0x02; | ||
| 693 | middle = packet[3] & 0x04; | ||
| 694 | |||
| 695 | /* To prevent the cursor jump when finger lifted */ | ||
| 696 | if (x == 0x7F && y == 0x7F && z == 0x7F) | ||
| 697 | x = y = z = 0; | ||
| 698 | |||
| 699 | /* Divide 4 since trackpoint's speed is too fast */ | ||
| 700 | input_report_rel(dev2, REL_X, (char)x / 4); | ||
| 701 | input_report_rel(dev2, REL_Y, -((char)y / 4)); | ||
| 702 | |||
| 703 | input_report_key(dev2, BTN_LEFT, left); | ||
| 704 | input_report_key(dev2, BTN_RIGHT, right); | ||
| 705 | input_report_key(dev2, BTN_MIDDLE, middle); | ||
| 706 | |||
| 707 | input_sync(dev2); | ||
| 708 | return; | ||
| 709 | } | ||
| 710 | |||
| 711 | /* Touchpad packet */ | ||
| 712 | x = packet[1] | ((packet[3] & 0x78) << 4); | ||
| 713 | y = packet[2] | ((packet[4] & 0x78) << 4); | ||
| 714 | z = packet[5]; | ||
| 715 | left = packet[3] & 0x01; | ||
| 716 | right = packet[3] & 0x02; | ||
| 717 | |||
| 718 | if (z > 30) | ||
| 719 | input_report_key(dev, BTN_TOUCH, 1); | ||
| 720 | if (z < 25) | ||
| 721 | input_report_key(dev, BTN_TOUCH, 0); | ||
| 722 | |||
| 723 | if (z > 0) { | ||
| 724 | input_report_abs(dev, ABS_X, x); | ||
| 725 | input_report_abs(dev, ABS_Y, y); | ||
| 726 | } | ||
| 727 | |||
| 728 | input_report_abs(dev, ABS_PRESSURE, z); | ||
| 729 | input_report_key(dev, BTN_TOOL_FINGER, z > 0); | ||
| 730 | |||
| 731 | /* v6 touchpad does not have middle button */ | ||
| 732 | input_report_key(dev, BTN_LEFT, left); | ||
| 733 | input_report_key(dev, BTN_RIGHT, right); | ||
| 734 | |||
| 735 | input_sync(dev); | ||
| 736 | } | ||
| 737 | |||
| 648 | static void alps_process_packet_v4(struct psmouse *psmouse) | 738 | static void alps_process_packet_v4(struct psmouse *psmouse) |
| 649 | { | 739 | { |
| 650 | struct alps_data *priv = psmouse->private; | 740 | struct alps_data *priv = psmouse->private; |
| @@ -897,7 +987,7 @@ static psmouse_ret_t alps_process_byte(struct psmouse *psmouse) | |||
| 897 | } | 987 | } |
| 898 | 988 | ||
| 899 | /* Bytes 2 - pktsize should have 0 in the highest bit */ | 989 | /* Bytes 2 - pktsize should have 0 in the highest bit */ |
| 900 | if (priv->proto_version != ALPS_PROTO_V5 && | 990 | if ((priv->proto_version < ALPS_PROTO_V5) && |
| 901 | psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize && | 991 | psmouse->pktcnt >= 2 && psmouse->pktcnt <= psmouse->pktsize && |
| 902 | (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) { | 992 | (psmouse->packet[psmouse->pktcnt - 1] & 0x80)) { |
| 903 | psmouse_dbg(psmouse, "refusing packet[%i] = %x\n", | 993 | psmouse_dbg(psmouse, "refusing packet[%i] = %x\n", |
| @@ -1085,6 +1175,80 @@ static int alps_absolute_mode_v1_v2(struct psmouse *psmouse) | |||
| 1085 | return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL); | 1175 | return ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETPOLL); |
| 1086 | } | 1176 | } |
| 1087 | 1177 | ||
| 1178 | static int alps_monitor_mode_send_word(struct psmouse *psmouse, u16 word) | ||
| 1179 | { | ||
| 1180 | int i, nibble; | ||
| 1181 | |||
| 1182 | /* | ||
| 1183 | * b0-b11 are valid bits, send sequence is inverse. | ||
| 1184 | * e.g. when word = 0x0123, nibble send sequence is 3, 2, 1 | ||
| 1185 | */ | ||
| 1186 | for (i = 0; i <= 8; i += 4) { | ||
| 1187 | nibble = (word >> i) & 0xf; | ||
| 1188 | if (alps_command_mode_send_nibble(psmouse, nibble)) | ||
| 1189 | return -1; | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | return 0; | ||
| 1193 | } | ||
| 1194 | |||
| 1195 | static int alps_monitor_mode_write_reg(struct psmouse *psmouse, | ||
| 1196 | u16 addr, u16 value) | ||
| 1197 | { | ||
| 1198 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
| 1199 | |||
| 1200 | /* 0x0A0 is the command to write the word */ | ||
| 1201 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_ENABLE) || | ||
| 1202 | alps_monitor_mode_send_word(psmouse, 0x0A0) || | ||
| 1203 | alps_monitor_mode_send_word(psmouse, addr) || | ||
| 1204 | alps_monitor_mode_send_word(psmouse, value) || | ||
| 1205 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE)) | ||
| 1206 | return -1; | ||
| 1207 | |||
| 1208 | return 0; | ||
| 1209 | } | ||
| 1210 | |||
| 1211 | static int alps_monitor_mode(struct psmouse *psmouse, bool enable) | ||
| 1212 | { | ||
| 1213 | struct ps2dev *ps2dev = &psmouse->ps2dev; | ||
| 1214 | |||
| 1215 | if (enable) { | ||
| 1216 | /* EC E9 F5 F5 E7 E6 E7 E9 to enter monitor mode */ | ||
| 1217 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP) || | ||
| 1218 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_GETINFO) || | ||
| 1219 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || | ||
| 1220 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_DISABLE) || | ||
| 1221 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || | ||
| 1222 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | ||
| 1223 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_SETSCALE21) || | ||
| 1224 | ps2_command(ps2dev, NULL, PSMOUSE_CMD_GETINFO)) | ||
| 1225 | return -1; | ||
| 1226 | } else { | ||
| 1227 | /* EC to exit monitor mode */ | ||
| 1228 | if (ps2_command(ps2dev, NULL, PSMOUSE_CMD_RESET_WRAP)) | ||
| 1229 | return -1; | ||
| 1230 | } | ||
| 1231 | |||
| 1232 | return 0; | ||
| 1233 | } | ||
| 1234 | |||
| 1235 | static int alps_absolute_mode_v6(struct psmouse *psmouse) | ||
| 1236 | { | ||
| 1237 | u16 reg_val = 0x181; | ||
| 1238 | int ret = -1; | ||
| 1239 | |||
| 1240 | /* enter monitor mode, to write the register */ | ||
| 1241 | if (alps_monitor_mode(psmouse, true)) | ||
| 1242 | return -1; | ||
| 1243 | |||
| 1244 | ret = alps_monitor_mode_write_reg(psmouse, 0x000, reg_val); | ||
| 1245 | |||
| 1246 | if (alps_monitor_mode(psmouse, false)) | ||
| 1247 | ret = -1; | ||
| 1248 | |||
| 1249 | return ret; | ||
| 1250 | } | ||
| 1251 | |||
| 1088 | static int alps_get_status(struct psmouse *psmouse, char *param) | 1252 | static int alps_get_status(struct psmouse *psmouse, char *param) |
| 1089 | { | 1253 | { |
| 1090 | /* Get status: 0xF5 0xF5 0xF5 0xE9 */ | 1254 | /* Get status: 0xF5 0xF5 0xF5 0xE9 */ |
| @@ -1189,6 +1353,32 @@ static int alps_hw_init_v1_v2(struct psmouse *psmouse) | |||
| 1189 | return 0; | 1353 | return 0; |
| 1190 | } | 1354 | } |
| 1191 | 1355 | ||
| 1356 | static int alps_hw_init_v6(struct psmouse *psmouse) | ||
| 1357 | { | ||
| 1358 | unsigned char param[2] = {0xC8, 0x14}; | ||
| 1359 | |||
| 1360 | /* Enter passthrough mode to let trackpoint enter 6byte raw mode */ | ||
| 1361 | if (alps_passthrough_mode_v2(psmouse, true)) | ||
| 1362 | return -1; | ||
| 1363 | |||
| 1364 | if (ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | ||
| 1365 | ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | ||
| 1366 | ps2_command(&psmouse->ps2dev, NULL, PSMOUSE_CMD_SETSCALE11) || | ||
| 1367 | ps2_command(&psmouse->ps2dev, ¶m[0], PSMOUSE_CMD_SETRATE) || | ||
| 1368 | ps2_command(&psmouse->ps2dev, ¶m[1], PSMOUSE_CMD_SETRATE)) | ||
| 1369 | return -1; | ||
| 1370 | |||
| 1371 | if (alps_passthrough_mode_v2(psmouse, false)) | ||
| 1372 | return -1; | ||
| 1373 | |||
| 1374 | if (alps_absolute_mode_v6(psmouse)) { | ||
| 1375 | psmouse_err(psmouse, "Failed to enable absolute mode\n"); | ||
| 1376 | return -1; | ||
| 1377 | } | ||
| 1378 | |||
| 1379 | return 0; | ||
| 1380 | } | ||
| 1381 | |||
| 1192 | /* | 1382 | /* |
| 1193 | * Enable or disable passthrough mode to the trackstick. | 1383 | * Enable or disable passthrough mode to the trackstick. |
| 1194 | */ | 1384 | */ |
| @@ -1553,6 +1743,8 @@ static void alps_set_defaults(struct alps_data *priv) | |||
| 1553 | priv->hw_init = alps_hw_init_v1_v2; | 1743 | priv->hw_init = alps_hw_init_v1_v2; |
| 1554 | priv->process_packet = alps_process_packet_v1_v2; | 1744 | priv->process_packet = alps_process_packet_v1_v2; |
| 1555 | priv->set_abs_params = alps_set_abs_params_st; | 1745 | priv->set_abs_params = alps_set_abs_params_st; |
| 1746 | priv->x_max = 1023; | ||
| 1747 | priv->y_max = 767; | ||
| 1556 | break; | 1748 | break; |
| 1557 | case ALPS_PROTO_V3: | 1749 | case ALPS_PROTO_V3: |
| 1558 | priv->hw_init = alps_hw_init_v3; | 1750 | priv->hw_init = alps_hw_init_v3; |
| @@ -1584,6 +1776,14 @@ static void alps_set_defaults(struct alps_data *priv) | |||
| 1584 | priv->x_bits = 23; | 1776 | priv->x_bits = 23; |
| 1585 | priv->y_bits = 12; | 1777 | priv->y_bits = 12; |
| 1586 | break; | 1778 | break; |
| 1779 | case ALPS_PROTO_V6: | ||
| 1780 | priv->hw_init = alps_hw_init_v6; | ||
| 1781 | priv->process_packet = alps_process_packet_v6; | ||
| 1782 | priv->set_abs_params = alps_set_abs_params_st; | ||
| 1783 | priv->nibble_commands = alps_v6_nibble_commands; | ||
| 1784 | priv->x_max = 2047; | ||
| 1785 | priv->y_max = 1535; | ||
| 1786 | break; | ||
| 1587 | } | 1787 | } |
| 1588 | } | 1788 | } |
| 1589 | 1789 | ||
| @@ -1705,8 +1905,8 @@ static void alps_disconnect(struct psmouse *psmouse) | |||
| 1705 | static void alps_set_abs_params_st(struct alps_data *priv, | 1905 | static void alps_set_abs_params_st(struct alps_data *priv, |
| 1706 | struct input_dev *dev1) | 1906 | struct input_dev *dev1) |
| 1707 | { | 1907 | { |
| 1708 | input_set_abs_params(dev1, ABS_X, 0, 1023, 0, 0); | 1908 | input_set_abs_params(dev1, ABS_X, 0, priv->x_max, 0, 0); |
| 1709 | input_set_abs_params(dev1, ABS_Y, 0, 767, 0, 0); | 1909 | input_set_abs_params(dev1, ABS_Y, 0, priv->y_max, 0, 0); |
| 1710 | } | 1910 | } |
| 1711 | 1911 | ||
| 1712 | static void alps_set_abs_params_mt(struct alps_data *priv, | 1912 | static void alps_set_abs_params_mt(struct alps_data *priv, |
diff --git a/drivers/input/mouse/alps.h b/drivers/input/mouse/alps.h index eee59853b9ce..704f0f924307 100644 --- a/drivers/input/mouse/alps.h +++ b/drivers/input/mouse/alps.h | |||
| @@ -17,6 +17,7 @@ | |||
| 17 | #define ALPS_PROTO_V3 3 | 17 | #define ALPS_PROTO_V3 3 |
| 18 | #define ALPS_PROTO_V4 4 | 18 | #define ALPS_PROTO_V4 4 |
| 19 | #define ALPS_PROTO_V5 5 | 19 | #define ALPS_PROTO_V5 5 |
| 20 | #define ALPS_PROTO_V6 6 | ||
| 20 | 21 | ||
| 21 | /** | 22 | /** |
| 22 | * struct alps_model_info - touchpad ID table | 23 | * struct alps_model_info - touchpad ID table |
diff --git a/drivers/input/mouse/elantech.c b/drivers/input/mouse/elantech.c index 8551dcaf24db..597e9b8fc18d 100644 --- a/drivers/input/mouse/elantech.c +++ b/drivers/input/mouse/elantech.c | |||
| @@ -1313,6 +1313,7 @@ static int elantech_set_properties(struct elantech_data *etd) | |||
| 1313 | break; | 1313 | break; |
| 1314 | case 6: | 1314 | case 6: |
| 1315 | case 7: | 1315 | case 7: |
| 1316 | case 8: | ||
| 1316 | etd->hw_version = 4; | 1317 | etd->hw_version = 4; |
| 1317 | break; | 1318 | break; |
| 1318 | default: | 1319 | default: |
diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c index 98707fb2cb5d..8f4c4ab04bc2 100644 --- a/drivers/input/serio/serio.c +++ b/drivers/input/serio/serio.c | |||
| @@ -455,16 +455,26 @@ static DEVICE_ATTR_RO(type); | |||
| 455 | static DEVICE_ATTR_RO(proto); | 455 | static DEVICE_ATTR_RO(proto); |
| 456 | static DEVICE_ATTR_RO(id); | 456 | static DEVICE_ATTR_RO(id); |
| 457 | static DEVICE_ATTR_RO(extra); | 457 | static DEVICE_ATTR_RO(extra); |
| 458 | static DEVICE_ATTR_RO(modalias); | ||
| 459 | static DEVICE_ATTR_WO(drvctl); | ||
| 460 | static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL); | ||
| 461 | static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode); | ||
| 462 | 458 | ||
| 463 | static struct attribute *serio_device_id_attrs[] = { | 459 | static struct attribute *serio_device_id_attrs[] = { |
| 464 | &dev_attr_type.attr, | 460 | &dev_attr_type.attr, |
| 465 | &dev_attr_proto.attr, | 461 | &dev_attr_proto.attr, |
| 466 | &dev_attr_id.attr, | 462 | &dev_attr_id.attr, |
| 467 | &dev_attr_extra.attr, | 463 | &dev_attr_extra.attr, |
| 464 | NULL | ||
| 465 | }; | ||
| 466 | |||
| 467 | static struct attribute_group serio_id_attr_group = { | ||
| 468 | .name = "id", | ||
| 469 | .attrs = serio_device_id_attrs, | ||
| 470 | }; | ||
| 471 | |||
| 472 | static DEVICE_ATTR_RO(modalias); | ||
| 473 | static DEVICE_ATTR_WO(drvctl); | ||
| 474 | static DEVICE_ATTR(description, S_IRUGO, serio_show_description, NULL); | ||
| 475 | static DEVICE_ATTR(bind_mode, S_IWUSR | S_IRUGO, serio_show_bind_mode, serio_set_bind_mode); | ||
| 476 | |||
| 477 | static struct attribute *serio_device_attrs[] = { | ||
| 468 | &dev_attr_modalias.attr, | 478 | &dev_attr_modalias.attr, |
| 469 | &dev_attr_description.attr, | 479 | &dev_attr_description.attr, |
| 470 | &dev_attr_drvctl.attr, | 480 | &dev_attr_drvctl.attr, |
| @@ -472,13 +482,13 @@ static struct attribute *serio_device_id_attrs[] = { | |||
| 472 | NULL | 482 | NULL |
| 473 | }; | 483 | }; |
| 474 | 484 | ||
| 475 | static struct attribute_group serio_id_attr_group = { | 485 | static struct attribute_group serio_device_attr_group = { |
| 476 | .name = "id", | 486 | .attrs = serio_device_attrs, |
| 477 | .attrs = serio_device_id_attrs, | ||
| 478 | }; | 487 | }; |
| 479 | 488 | ||
| 480 | static const struct attribute_group *serio_device_attr_groups[] = { | 489 | static const struct attribute_group *serio_device_attr_groups[] = { |
| 481 | &serio_id_attr_group, | 490 | &serio_id_attr_group, |
| 491 | &serio_device_attr_group, | ||
| 482 | NULL | 492 | NULL |
| 483 | }; | 493 | }; |
| 484 | 494 | ||
diff --git a/drivers/input/touchscreen/Kconfig b/drivers/input/touchscreen/Kconfig index 00d1e547b211..961d58d32647 100644 --- a/drivers/input/touchscreen/Kconfig +++ b/drivers/input/touchscreen/Kconfig | |||
| @@ -906,6 +906,17 @@ config TOUCHSCREEN_STMPE | |||
| 906 | To compile this driver as a module, choose M here: the | 906 | To compile this driver as a module, choose M here: the |
| 907 | module will be called stmpe-ts. | 907 | module will be called stmpe-ts. |
| 908 | 908 | ||
| 909 | config TOUCHSCREEN_SUR40 | ||
| 910 | tristate "Samsung SUR40 (Surface 2.0/PixelSense) touchscreen" | ||
| 911 | depends on USB | ||
| 912 | select INPUT_POLLDEV | ||
| 913 | help | ||
| 914 | Say Y here if you want support for the Samsung SUR40 touchscreen | ||
| 915 | (also known as Microsoft Surface 2.0 or Microsoft PixelSense). | ||
| 916 | |||
| 917 | To compile this driver as a module, choose M here: the | ||
| 918 | module will be called sur40. | ||
| 919 | |||
| 909 | config TOUCHSCREEN_TPS6507X | 920 | config TOUCHSCREEN_TPS6507X |
| 910 | tristate "TPS6507x based touchscreens" | 921 | tristate "TPS6507x based touchscreens" |
| 911 | depends on I2C | 922 | depends on I2C |
diff --git a/drivers/input/touchscreen/Makefile b/drivers/input/touchscreen/Makefile index 7587883b8d38..62801f213346 100644 --- a/drivers/input/touchscreen/Makefile +++ b/drivers/input/touchscreen/Makefile | |||
| @@ -54,6 +54,7 @@ obj-$(CONFIG_TOUCHSCREEN_PIXCIR) += pixcir_i2c_ts.o | |||
| 54 | obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o | 54 | obj-$(CONFIG_TOUCHSCREEN_S3C2410) += s3c2410_ts.o |
| 55 | obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o | 55 | obj-$(CONFIG_TOUCHSCREEN_ST1232) += st1232.o |
| 56 | obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o | 56 | obj-$(CONFIG_TOUCHSCREEN_STMPE) += stmpe-ts.o |
| 57 | obj-$(CONFIG_TOUCHSCREEN_SUR40) += sur40.o | ||
| 57 | obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o | 58 | obj-$(CONFIG_TOUCHSCREEN_TI_AM335X_TSC) += ti_am335x_tsc.o |
| 58 | obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o | 59 | obj-$(CONFIG_TOUCHSCREEN_TNETV107X) += tnetv107x-ts.o |
| 59 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o | 60 | obj-$(CONFIG_TOUCHSCREEN_TOUCHIT213) += touchit213.o |
diff --git a/drivers/input/touchscreen/atmel-wm97xx.c b/drivers/input/touchscreen/atmel-wm97xx.c index 268a35e55d7f..279c0e42b8a7 100644 --- a/drivers/input/touchscreen/atmel-wm97xx.c +++ b/drivers/input/touchscreen/atmel-wm97xx.c | |||
| @@ -391,7 +391,7 @@ static int __exit atmel_wm97xx_remove(struct platform_device *pdev) | |||
| 391 | } | 391 | } |
| 392 | 392 | ||
| 393 | #ifdef CONFIG_PM_SLEEP | 393 | #ifdef CONFIG_PM_SLEEP |
| 394 | static int atmel_wm97xx_suspend(struct *dev) | 394 | static int atmel_wm97xx_suspend(struct device *dev) |
| 395 | { | 395 | { |
| 396 | struct platform_device *pdev = to_platform_device(dev); | 396 | struct platform_device *pdev = to_platform_device(dev); |
| 397 | struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev); | 397 | struct atmel_wm97xx *atmel_wm97xx = platform_get_drvdata(pdev); |
diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 42d830efa316..a035a390f8e2 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c | |||
| @@ -1246,8 +1246,7 @@ static void cyttsp4_watchdog_timer(unsigned long handle) | |||
| 1246 | 1246 | ||
| 1247 | dev_vdbg(cd->dev, "%s: Watchdog timer triggered\n", __func__); | 1247 | dev_vdbg(cd->dev, "%s: Watchdog timer triggered\n", __func__); |
| 1248 | 1248 | ||
| 1249 | if (!work_pending(&cd->watchdog_work)) | 1249 | schedule_work(&cd->watchdog_work); |
| 1250 | schedule_work(&cd->watchdog_work); | ||
| 1251 | 1250 | ||
| 1252 | return; | 1251 | return; |
| 1253 | } | 1252 | } |
diff --git a/drivers/input/touchscreen/sur40.c b/drivers/input/touchscreen/sur40.c new file mode 100644 index 000000000000..f1cb05148b46 --- /dev/null +++ b/drivers/input/touchscreen/sur40.c | |||
| @@ -0,0 +1,466 @@ | |||
| 1 | /* | ||
| 2 | * Surface2.0/SUR40/PixelSense input driver | ||
| 3 | * | ||
| 4 | * Copyright (c) 2013 by Florian 'floe' Echtler <floe@butterbrot.org> | ||
| 5 | * | ||
| 6 | * Derived from the USB Skeleton driver 1.1, | ||
| 7 | * Copyright (c) 2003 Greg Kroah-Hartman (greg@kroah.com) | ||
| 8 | * | ||
| 9 | * and from the Apple USB BCM5974 multitouch driver, | ||
| 10 | * Copyright (c) 2008 Henrik Rydberg (rydberg@euromail.se) | ||
| 11 | * | ||
| 12 | * and from the generic hid-multitouch driver, | ||
| 13 | * Copyright (c) 2010-2012 Stephane Chatty <chatty@enac.fr> | ||
| 14 | * | ||
| 15 | * This program is free software; you can redistribute it and/or | ||
| 16 | * modify it under the terms of the GNU General Public License as | ||
| 17 | * published by the Free Software Foundation; either version 2 of | ||
| 18 | * the License, or (at your option) any later version. | ||
| 19 | */ | ||
| 20 | |||
| 21 | #include <linux/kernel.h> | ||
| 22 | #include <linux/errno.h> | ||
| 23 | #include <linux/delay.h> | ||
| 24 | #include <linux/init.h> | ||
| 25 | #include <linux/slab.h> | ||
| 26 | #include <linux/module.h> | ||
| 27 | #include <linux/completion.h> | ||
| 28 | #include <linux/uaccess.h> | ||
| 29 | #include <linux/usb.h> | ||
| 30 | #include <linux/printk.h> | ||
| 31 | #include <linux/input-polldev.h> | ||
| 32 | #include <linux/input/mt.h> | ||
| 33 | #include <linux/usb/input.h> | ||
| 34 | |||
| 35 | /* read 512 bytes from endpoint 0x86 -> get header + blobs */ | ||
| 36 | struct sur40_header { | ||
| 37 | |||
| 38 | __le16 type; /* always 0x0001 */ | ||
| 39 | __le16 count; /* count of blobs (if 0: continue prev. packet) */ | ||
| 40 | |||
| 41 | __le32 packet_id; /* unique ID for all packets in one frame */ | ||
| 42 | |||
| 43 | __le32 timestamp; /* milliseconds (inc. by 16 or 17 each frame) */ | ||
| 44 | __le32 unknown; /* "epoch?" always 02/03 00 00 00 */ | ||
| 45 | |||
| 46 | } __packed; | ||
| 47 | |||
| 48 | struct sur40_blob { | ||
| 49 | |||
| 50 | __le16 blob_id; | ||
| 51 | |||
| 52 | u8 action; /* 0x02 = enter/exit, 0x03 = update (?) */ | ||
| 53 | u8 unknown; /* always 0x01 or 0x02 (no idea what this is?) */ | ||
| 54 | |||
| 55 | __le16 bb_pos_x; /* upper left corner of bounding box */ | ||
| 56 | __le16 bb_pos_y; | ||
| 57 | |||
| 58 | __le16 bb_size_x; /* size of bounding box */ | ||
| 59 | __le16 bb_size_y; | ||
| 60 | |||
| 61 | __le16 pos_x; /* finger tip position */ | ||
| 62 | __le16 pos_y; | ||
| 63 | |||
| 64 | __le16 ctr_x; /* centroid position */ | ||
| 65 | __le16 ctr_y; | ||
| 66 | |||
| 67 | __le16 axis_x; /* somehow related to major/minor axis, mostly: */ | ||
| 68 | __le16 axis_y; /* axis_x == bb_size_y && axis_y == bb_size_x */ | ||
| 69 | |||
| 70 | __le32 angle; /* orientation in radians relative to x axis - | ||
| 71 | actually an IEEE754 float, don't use in kernel */ | ||
| 72 | |||
| 73 | __le32 area; /* size in pixels/pressure (?) */ | ||
| 74 | |||
| 75 | u8 padding[32]; | ||
| 76 | |||
| 77 | } __packed; | ||
| 78 | |||
| 79 | /* combined header/blob data */ | ||
| 80 | struct sur40_data { | ||
| 81 | struct sur40_header header; | ||
| 82 | struct sur40_blob blobs[]; | ||
| 83 | } __packed; | ||
| 84 | |||
| 85 | |||
| 86 | /* version information */ | ||
| 87 | #define DRIVER_SHORT "sur40" | ||
| 88 | #define DRIVER_AUTHOR "Florian 'floe' Echtler <floe@butterbrot.org>" | ||
| 89 | #define DRIVER_DESC "Surface2.0/SUR40/PixelSense input driver" | ||
| 90 | |||
| 91 | /* vendor and device IDs */ | ||
| 92 | #define ID_MICROSOFT 0x045e | ||
| 93 | #define ID_SUR40 0x0775 | ||
| 94 | |||
| 95 | /* sensor resolution */ | ||
| 96 | #define SENSOR_RES_X 1920 | ||
| 97 | #define SENSOR_RES_Y 1080 | ||
| 98 | |||
| 99 | /* touch data endpoint */ | ||
| 100 | #define TOUCH_ENDPOINT 0x86 | ||
| 101 | |||
| 102 | /* polling interval (ms) */ | ||
| 103 | #define POLL_INTERVAL 10 | ||
| 104 | |||
| 105 | /* maximum number of contacts FIXME: this is a guess? */ | ||
| 106 | #define MAX_CONTACTS 64 | ||
| 107 | |||
| 108 | /* control commands */ | ||
| 109 | #define SUR40_GET_VERSION 0xb0 /* 12 bytes string */ | ||
| 110 | #define SUR40_UNKNOWN1 0xb3 /* 5 bytes */ | ||
| 111 | #define SUR40_UNKNOWN2 0xc1 /* 24 bytes */ | ||
| 112 | |||
| 113 | #define SUR40_GET_STATE 0xc5 /* 4 bytes state (?) */ | ||
| 114 | #define SUR40_GET_SENSORS 0xb1 /* 8 bytes sensors */ | ||
| 115 | |||
| 116 | /* | ||
| 117 | * Note: an earlier, non-public version of this driver used USB_RECIP_ENDPOINT | ||
| 118 | * here by mistake which is very likely to have corrupted the firmware EEPROM | ||
| 119 | * on two separate SUR40 devices. Thanks to Alan Stern who spotted this bug. | ||
| 120 | * Should you ever run into a similar problem, the background story to this | ||
| 121 | * incident and instructions on how to fix the corrupted EEPROM are available | ||
| 122 | * at https://floe.butterbrot.org/matrix/hacking/surface/brick.html | ||
| 123 | */ | ||
| 124 | |||
| 125 | struct sur40_state { | ||
| 126 | |||
| 127 | struct usb_device *usbdev; | ||
| 128 | struct device *dev; | ||
| 129 | struct input_polled_dev *input; | ||
| 130 | |||
| 131 | struct sur40_data *bulk_in_buffer; | ||
| 132 | size_t bulk_in_size; | ||
| 133 | u8 bulk_in_epaddr; | ||
| 134 | |||
| 135 | char phys[64]; | ||
| 136 | }; | ||
| 137 | |||
| 138 | static int sur40_command(struct sur40_state *dev, | ||
| 139 | u8 command, u16 index, void *buffer, u16 size) | ||
| 140 | { | ||
| 141 | return usb_control_msg(dev->usbdev, usb_rcvctrlpipe(dev->usbdev, 0), | ||
| 142 | command, | ||
| 143 | USB_TYPE_VENDOR | USB_RECIP_DEVICE | USB_DIR_IN, | ||
| 144 | 0x00, index, buffer, size, 1000); | ||
| 145 | } | ||
| 146 | |||
| 147 | /* Initialization routine, called from sur40_open */ | ||
| 148 | static int sur40_init(struct sur40_state *dev) | ||
| 149 | { | ||
| 150 | int result; | ||
| 151 | u8 buffer[24]; | ||
| 152 | |||
| 153 | /* stupidly replay the original MS driver init sequence */ | ||
| 154 | result = sur40_command(dev, SUR40_GET_VERSION, 0x00, buffer, 12); | ||
| 155 | if (result < 0) | ||
| 156 | return result; | ||
| 157 | |||
| 158 | result = sur40_command(dev, SUR40_GET_VERSION, 0x01, buffer, 12); | ||
| 159 | if (result < 0) | ||
| 160 | return result; | ||
| 161 | |||
| 162 | result = sur40_command(dev, SUR40_GET_VERSION, 0x02, buffer, 12); | ||
| 163 | if (result < 0) | ||
| 164 | return result; | ||
| 165 | |||
| 166 | result = sur40_command(dev, SUR40_UNKNOWN2, 0x00, buffer, 24); | ||
| 167 | if (result < 0) | ||
| 168 | return result; | ||
| 169 | |||
| 170 | result = sur40_command(dev, SUR40_UNKNOWN1, 0x00, buffer, 5); | ||
| 171 | if (result < 0) | ||
| 172 | return result; | ||
| 173 | |||
| 174 | result = sur40_command(dev, SUR40_GET_VERSION, 0x03, buffer, 12); | ||
| 175 | |||
| 176 | /* | ||
| 177 | * Discard the result buffer - no known data inside except | ||
| 178 | * some version strings, maybe extract these sometime... | ||
| 179 | */ | ||
| 180 | |||
| 181 | return result; | ||
| 182 | } | ||
| 183 | |||
| 184 | /* | ||
| 185 | * Callback routines from input_polled_dev | ||
| 186 | */ | ||
| 187 | |||
| 188 | /* Enable the device, polling will now start. */ | ||
| 189 | static void sur40_open(struct input_polled_dev *polldev) | ||
| 190 | { | ||
| 191 | struct sur40_state *sur40 = polldev->private; | ||
| 192 | |||
| 193 | dev_dbg(sur40->dev, "open\n"); | ||
| 194 | sur40_init(sur40); | ||
| 195 | } | ||
| 196 | |||
| 197 | /* Disable device, polling has stopped. */ | ||
| 198 | static void sur40_close(struct input_polled_dev *polldev) | ||
| 199 | { | ||
| 200 | struct sur40_state *sur40 = polldev->private; | ||
| 201 | |||
| 202 | dev_dbg(sur40->dev, "close\n"); | ||
| 203 | /* | ||
| 204 | * There is no known way to stop the device, so we simply | ||
| 205 | * stop polling. | ||
| 206 | */ | ||
| 207 | } | ||
| 208 | |||
| 209 | /* | ||
| 210 | * This function is called when a whole contact has been processed, | ||
| 211 | * so that it can assign it to a slot and store the data there. | ||
| 212 | */ | ||
| 213 | static void sur40_report_blob(struct sur40_blob *blob, struct input_dev *input) | ||
| 214 | { | ||
| 215 | int wide, major, minor; | ||
| 216 | |||
| 217 | int bb_size_x = le16_to_cpu(blob->bb_size_x); | ||
| 218 | int bb_size_y = le16_to_cpu(blob->bb_size_y); | ||
| 219 | |||
| 220 | int pos_x = le16_to_cpu(blob->pos_x); | ||
| 221 | int pos_y = le16_to_cpu(blob->pos_y); | ||
| 222 | |||
| 223 | int ctr_x = le16_to_cpu(blob->ctr_x); | ||
| 224 | int ctr_y = le16_to_cpu(blob->ctr_y); | ||
| 225 | |||
| 226 | int slotnum = input_mt_get_slot_by_key(input, blob->blob_id); | ||
| 227 | if (slotnum < 0 || slotnum >= MAX_CONTACTS) | ||
| 228 | return; | ||
| 229 | |||
| 230 | input_mt_slot(input, slotnum); | ||
| 231 | input_mt_report_slot_state(input, MT_TOOL_FINGER, 1); | ||
| 232 | wide = (bb_size_x > bb_size_y); | ||
| 233 | major = max(bb_size_x, bb_size_y); | ||
| 234 | minor = min(bb_size_x, bb_size_y); | ||
| 235 | |||
| 236 | input_report_abs(input, ABS_MT_POSITION_X, pos_x); | ||
| 237 | input_report_abs(input, ABS_MT_POSITION_Y, pos_y); | ||
| 238 | input_report_abs(input, ABS_MT_TOOL_X, ctr_x); | ||
| 239 | input_report_abs(input, ABS_MT_TOOL_Y, ctr_y); | ||
| 240 | |||
| 241 | /* TODO: use a better orientation measure */ | ||
| 242 | input_report_abs(input, ABS_MT_ORIENTATION, wide); | ||
| 243 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, major); | ||
| 244 | input_report_abs(input, ABS_MT_TOUCH_MINOR, minor); | ||
| 245 | } | ||
| 246 | |||
| 247 | /* core function: poll for new input data */ | ||
| 248 | static void sur40_poll(struct input_polled_dev *polldev) | ||
| 249 | { | ||
| 250 | |||
| 251 | struct sur40_state *sur40 = polldev->private; | ||
| 252 | struct input_dev *input = polldev->input; | ||
| 253 | int result, bulk_read, need_blobs, packet_blobs, i; | ||
| 254 | u32 uninitialized_var(packet_id); | ||
| 255 | |||
| 256 | struct sur40_header *header = &sur40->bulk_in_buffer->header; | ||
| 257 | struct sur40_blob *inblob = &sur40->bulk_in_buffer->blobs[0]; | ||
| 258 | |||
| 259 | dev_dbg(sur40->dev, "poll\n"); | ||
| 260 | |||
| 261 | need_blobs = -1; | ||
| 262 | |||
| 263 | do { | ||
| 264 | |||
| 265 | /* perform a blocking bulk read to get data from the device */ | ||
| 266 | result = usb_bulk_msg(sur40->usbdev, | ||
| 267 | usb_rcvbulkpipe(sur40->usbdev, sur40->bulk_in_epaddr), | ||
| 268 | sur40->bulk_in_buffer, sur40->bulk_in_size, | ||
| 269 | &bulk_read, 1000); | ||
| 270 | |||
| 271 | dev_dbg(sur40->dev, "received %d bytes\n", bulk_read); | ||
| 272 | |||
| 273 | if (result < 0) { | ||
| 274 | dev_err(sur40->dev, "error in usb_bulk_read\n"); | ||
| 275 | return; | ||
| 276 | } | ||
| 277 | |||
| 278 | result = bulk_read - sizeof(struct sur40_header); | ||
| 279 | |||
| 280 | if (result % sizeof(struct sur40_blob) != 0) { | ||
| 281 | dev_err(sur40->dev, "transfer size mismatch\n"); | ||
| 282 | return; | ||
| 283 | } | ||
| 284 | |||
| 285 | /* first packet? */ | ||
| 286 | if (need_blobs == -1) { | ||
| 287 | need_blobs = le16_to_cpu(header->count); | ||
| 288 | dev_dbg(sur40->dev, "need %d blobs\n", need_blobs); | ||
| 289 | packet_id = le32_to_cpu(header->packet_id); | ||
| 290 | } | ||
| 291 | |||
| 292 | /* | ||
| 293 | * Sanity check. when video data is also being retrieved, the | ||
| 294 | * packet ID will usually increase in the middle of a series | ||
| 295 | * instead of at the end. | ||
| 296 | */ | ||
| 297 | if (packet_id != header->packet_id) | ||
| 298 | dev_warn(sur40->dev, "packet ID mismatch\n"); | ||
| 299 | |||
| 300 | packet_blobs = result / sizeof(struct sur40_blob); | ||
| 301 | dev_dbg(sur40->dev, "received %d blobs\n", packet_blobs); | ||
| 302 | |||
| 303 | /* packets always contain at least 4 blobs, even if empty */ | ||
| 304 | if (packet_blobs > need_blobs) | ||
| 305 | packet_blobs = need_blobs; | ||
| 306 | |||
| 307 | for (i = 0; i < packet_blobs; i++) { | ||
| 308 | need_blobs--; | ||
| 309 | dev_dbg(sur40->dev, "processing blob\n"); | ||
| 310 | sur40_report_blob(&(inblob[i]), input); | ||
| 311 | } | ||
| 312 | |||
| 313 | } while (need_blobs > 0); | ||
| 314 | |||
| 315 | input_mt_sync_frame(input); | ||
| 316 | input_sync(input); | ||
| 317 | } | ||
| 318 | |||
| 319 | /* Initialize input device parameters. */ | ||
| 320 | static void sur40_input_setup(struct input_dev *input_dev) | ||
| 321 | { | ||
| 322 | __set_bit(EV_KEY, input_dev->evbit); | ||
| 323 | __set_bit(EV_ABS, input_dev->evbit); | ||
| 324 | |||
| 325 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | ||
| 326 | 0, SENSOR_RES_X, 0, 0); | ||
| 327 | input_set_abs_params(input_dev, ABS_MT_POSITION_Y, | ||
| 328 | 0, SENSOR_RES_Y, 0, 0); | ||
| 329 | |||
| 330 | input_set_abs_params(input_dev, ABS_MT_TOOL_X, | ||
| 331 | 0, SENSOR_RES_X, 0, 0); | ||
| 332 | input_set_abs_params(input_dev, ABS_MT_TOOL_Y, | ||
| 333 | 0, SENSOR_RES_Y, 0, 0); | ||
| 334 | |||
| 335 | /* max value unknown, but major/minor axis | ||
| 336 | * can never be larger than screen */ | ||
| 337 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | ||
| 338 | 0, SENSOR_RES_X, 0, 0); | ||
| 339 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, | ||
| 340 | 0, SENSOR_RES_Y, 0, 0); | ||
| 341 | |||
| 342 | input_set_abs_params(input_dev, ABS_MT_ORIENTATION, 0, 1, 0, 0); | ||
| 343 | |||
| 344 | input_mt_init_slots(input_dev, MAX_CONTACTS, | ||
| 345 | INPUT_MT_DIRECT | INPUT_MT_DROP_UNUSED); | ||
| 346 | } | ||
| 347 | |||
| 348 | /* Check candidate USB interface. */ | ||
| 349 | static int sur40_probe(struct usb_interface *interface, | ||
| 350 | const struct usb_device_id *id) | ||
| 351 | { | ||
| 352 | struct usb_device *usbdev = interface_to_usbdev(interface); | ||
| 353 | struct sur40_state *sur40; | ||
| 354 | struct usb_host_interface *iface_desc; | ||
| 355 | struct usb_endpoint_descriptor *endpoint; | ||
| 356 | struct input_polled_dev *poll_dev; | ||
| 357 | int error; | ||
| 358 | |||
| 359 | /* Check if we really have the right interface. */ | ||
| 360 | iface_desc = &interface->altsetting[0]; | ||
| 361 | if (iface_desc->desc.bInterfaceClass != 0xFF) | ||
| 362 | return -ENODEV; | ||
| 363 | |||
| 364 | /* Use endpoint #4 (0x86). */ | ||
| 365 | endpoint = &iface_desc->endpoint[4].desc; | ||
| 366 | if (endpoint->bEndpointAddress != TOUCH_ENDPOINT) | ||
| 367 | return -ENODEV; | ||
| 368 | |||
| 369 | /* Allocate memory for our device state and initialize it. */ | ||
| 370 | sur40 = kzalloc(sizeof(struct sur40_state), GFP_KERNEL); | ||
| 371 | if (!sur40) | ||
| 372 | return -ENOMEM; | ||
| 373 | |||
| 374 | poll_dev = input_allocate_polled_device(); | ||
| 375 | if (!poll_dev) { | ||
| 376 | error = -ENOMEM; | ||
| 377 | goto err_free_dev; | ||
| 378 | } | ||
| 379 | |||
| 380 | /* Set up polled input device control structure */ | ||
| 381 | poll_dev->private = sur40; | ||
| 382 | poll_dev->poll_interval = POLL_INTERVAL; | ||
| 383 | poll_dev->open = sur40_open; | ||
| 384 | poll_dev->poll = sur40_poll; | ||
| 385 | poll_dev->close = sur40_close; | ||
| 386 | |||
| 387 | /* Set up regular input device structure */ | ||
| 388 | sur40_input_setup(poll_dev->input); | ||
| 389 | |||
| 390 | poll_dev->input->name = "Samsung SUR40"; | ||
| 391 | usb_to_input_id(usbdev, &poll_dev->input->id); | ||
| 392 | usb_make_path(usbdev, sur40->phys, sizeof(sur40->phys)); | ||
| 393 | strlcat(sur40->phys, "/input0", sizeof(sur40->phys)); | ||
| 394 | poll_dev->input->phys = sur40->phys; | ||
| 395 | poll_dev->input->dev.parent = &interface->dev; | ||
| 396 | |||
| 397 | sur40->usbdev = usbdev; | ||
| 398 | sur40->dev = &interface->dev; | ||
| 399 | sur40->input = poll_dev; | ||
| 400 | |||
| 401 | /* use the bulk-in endpoint tested above */ | ||
| 402 | sur40->bulk_in_size = usb_endpoint_maxp(endpoint); | ||
| 403 | sur40->bulk_in_epaddr = endpoint->bEndpointAddress; | ||
| 404 | sur40->bulk_in_buffer = kmalloc(sur40->bulk_in_size, GFP_KERNEL); | ||
| 405 | if (!sur40->bulk_in_buffer) { | ||
| 406 | dev_err(&interface->dev, "Unable to allocate input buffer."); | ||
| 407 | error = -ENOMEM; | ||
| 408 | goto err_free_polldev; | ||
| 409 | } | ||
| 410 | |||
| 411 | error = input_register_polled_device(poll_dev); | ||
| 412 | if (error) { | ||
| 413 | dev_err(&interface->dev, | ||
| 414 | "Unable to register polled input device."); | ||
| 415 | goto err_free_buffer; | ||
| 416 | } | ||
| 417 | |||
| 418 | /* we can register the device now, as it is ready */ | ||
| 419 | usb_set_intfdata(interface, sur40); | ||
| 420 | dev_dbg(&interface->dev, "%s is now attached\n", DRIVER_DESC); | ||
| 421 | |||
| 422 | return 0; | ||
| 423 | |||
| 424 | err_free_buffer: | ||
| 425 | kfree(sur40->bulk_in_buffer); | ||
| 426 | err_free_polldev: | ||
| 427 | input_free_polled_device(sur40->input); | ||
| 428 | err_free_dev: | ||
| 429 | kfree(sur40); | ||
| 430 | |||
| 431 | return error; | ||
| 432 | } | ||
| 433 | |||
| 434 | /* Unregister device & clean up. */ | ||
| 435 | static void sur40_disconnect(struct usb_interface *interface) | ||
| 436 | { | ||
| 437 | struct sur40_state *sur40 = usb_get_intfdata(interface); | ||
| 438 | |||
| 439 | input_unregister_polled_device(sur40->input); | ||
| 440 | input_free_polled_device(sur40->input); | ||
| 441 | kfree(sur40->bulk_in_buffer); | ||
| 442 | kfree(sur40); | ||
| 443 | |||
| 444 | usb_set_intfdata(interface, NULL); | ||
| 445 | dev_dbg(&interface->dev, "%s is now disconnected\n", DRIVER_DESC); | ||
| 446 | } | ||
| 447 | |||
| 448 | static const struct usb_device_id sur40_table[] = { | ||
| 449 | { USB_DEVICE(ID_MICROSOFT, ID_SUR40) }, /* Samsung SUR40 */ | ||
| 450 | { } /* terminating null entry */ | ||
| 451 | }; | ||
| 452 | MODULE_DEVICE_TABLE(usb, sur40_table); | ||
| 453 | |||
| 454 | /* USB-specific object needed to register this driver with the USB subsystem. */ | ||
| 455 | static struct usb_driver sur40_driver = { | ||
| 456 | .name = DRIVER_SHORT, | ||
| 457 | .probe = sur40_probe, | ||
| 458 | .disconnect = sur40_disconnect, | ||
| 459 | .id_table = sur40_table, | ||
| 460 | }; | ||
| 461 | |||
| 462 | module_usb_driver(sur40_driver); | ||
| 463 | |||
| 464 | MODULE_AUTHOR(DRIVER_AUTHOR); | ||
| 465 | MODULE_DESCRIPTION(DRIVER_DESC); | ||
| 466 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/input/touchscreen/usbtouchscreen.c b/drivers/input/touchscreen/usbtouchscreen.c index ae4b6b903629..5f87bed05467 100644 --- a/drivers/input/touchscreen/usbtouchscreen.c +++ b/drivers/input/touchscreen/usbtouchscreen.c | |||
| @@ -106,6 +106,7 @@ struct usbtouch_device_info { | |||
| 106 | struct usbtouch_usb { | 106 | struct usbtouch_usb { |
| 107 | unsigned char *data; | 107 | unsigned char *data; |
| 108 | dma_addr_t data_dma; | 108 | dma_addr_t data_dma; |
| 109 | int data_size; | ||
| 109 | unsigned char *buffer; | 110 | unsigned char *buffer; |
| 110 | int buf_len; | 111 | int buf_len; |
| 111 | struct urb *irq; | 112 | struct urb *irq; |
| @@ -1521,7 +1522,7 @@ static int usbtouch_reset_resume(struct usb_interface *intf) | |||
| 1521 | static void usbtouch_free_buffers(struct usb_device *udev, | 1522 | static void usbtouch_free_buffers(struct usb_device *udev, |
| 1522 | struct usbtouch_usb *usbtouch) | 1523 | struct usbtouch_usb *usbtouch) |
| 1523 | { | 1524 | { |
| 1524 | usb_free_coherent(udev, usbtouch->type->rept_size, | 1525 | usb_free_coherent(udev, usbtouch->data_size, |
| 1525 | usbtouch->data, usbtouch->data_dma); | 1526 | usbtouch->data, usbtouch->data_dma); |
| 1526 | kfree(usbtouch->buffer); | 1527 | kfree(usbtouch->buffer); |
| 1527 | } | 1528 | } |
| @@ -1566,7 +1567,20 @@ static int usbtouch_probe(struct usb_interface *intf, | |||
| 1566 | if (!type->process_pkt) | 1567 | if (!type->process_pkt) |
| 1567 | type->process_pkt = usbtouch_process_pkt; | 1568 | type->process_pkt = usbtouch_process_pkt; |
| 1568 | 1569 | ||
| 1569 | usbtouch->data = usb_alloc_coherent(udev, type->rept_size, | 1570 | usbtouch->data_size = type->rept_size; |
| 1571 | if (type->get_pkt_len) { | ||
| 1572 | /* | ||
| 1573 | * When dealing with variable-length packets we should | ||
| 1574 | * not request more than wMaxPacketSize bytes at once | ||
| 1575 | * as we do not know if there is more data coming or | ||
| 1576 | * we filled exactly wMaxPacketSize bytes and there is | ||
| 1577 | * nothing else. | ||
| 1578 | */ | ||
| 1579 | usbtouch->data_size = min(usbtouch->data_size, | ||
| 1580 | usb_endpoint_maxp(endpoint)); | ||
| 1581 | } | ||
| 1582 | |||
| 1583 | usbtouch->data = usb_alloc_coherent(udev, usbtouch->data_size, | ||
| 1570 | GFP_KERNEL, &usbtouch->data_dma); | 1584 | GFP_KERNEL, &usbtouch->data_dma); |
| 1571 | if (!usbtouch->data) | 1585 | if (!usbtouch->data) |
| 1572 | goto out_free; | 1586 | goto out_free; |
| @@ -1626,12 +1640,12 @@ static int usbtouch_probe(struct usb_interface *intf, | |||
| 1626 | if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT) | 1640 | if (usb_endpoint_type(endpoint) == USB_ENDPOINT_XFER_INT) |
| 1627 | usb_fill_int_urb(usbtouch->irq, udev, | 1641 | usb_fill_int_urb(usbtouch->irq, udev, |
| 1628 | usb_rcvintpipe(udev, endpoint->bEndpointAddress), | 1642 | usb_rcvintpipe(udev, endpoint->bEndpointAddress), |
| 1629 | usbtouch->data, type->rept_size, | 1643 | usbtouch->data, usbtouch->data_size, |
| 1630 | usbtouch_irq, usbtouch, endpoint->bInterval); | 1644 | usbtouch_irq, usbtouch, endpoint->bInterval); |
| 1631 | else | 1645 | else |
| 1632 | usb_fill_bulk_urb(usbtouch->irq, udev, | 1646 | usb_fill_bulk_urb(usbtouch->irq, udev, |
| 1633 | usb_rcvbulkpipe(udev, endpoint->bEndpointAddress), | 1647 | usb_rcvbulkpipe(udev, endpoint->bEndpointAddress), |
| 1634 | usbtouch->data, type->rept_size, | 1648 | usbtouch->data, usbtouch->data_size, |
| 1635 | usbtouch_irq, usbtouch); | 1649 | usbtouch_irq, usbtouch); |
| 1636 | 1650 | ||
| 1637 | usbtouch->irq->dev = udev; | 1651 | usbtouch->irq->dev = udev; |
