Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input

Pull input updates from Dmitry Torokhov:

- an update to Elan touchpad SMBus driver to fetch device parameters
(size, resolution) while it is still in PS/2 mode, before switching
over to SMBus, as in that mode some devices return garbage dimensions

- update to iforce joystick driver

- miscellaneous driver fixes

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input: (48 commits)
Input: gpio_keys_polled - allow specifying name of input device
Input: edt-ft5x06 - simplify event reporting code
Input: max77650-onkey - add MODULE_ALIAS()
Input: atmel_mxt_ts - fix leak in mxt_update_cfg()
Input: synaptics - enable SMBUS on T480 thinkpad trackpad
Input: atmel_mxt_ts - fix -Wunused-const-variable
Input: joydev - extend absolute mouse detection
HID: quirks: Refactor ELAN 400 and 401 handling
Input: elan_i2c - export the device id whitelist
Input: edt-ft5x06 - use get_unaligned_be16()
Input: iforce - add the Saitek R440 Force Wheel
Input: iforce - use unaligned accessors, where appropriate
Input: iforce - drop couple of temps from transport code
Input: iforce - drop bus type from iforce structure
Input: iforce - use DMA-safe buffores for USB transfers
Input: iforce - allow callers supply data buffer when fetching device IDs
Input: iforce - only call iforce_process_packet() if initialized
Input: iforce - signal command completion from transport code
Input: iforce - do not combine arguments for iforce_process_packet()
Input: iforce - factor out hat handling when parsing packets
...

+875 -714
+11
Documentation/devicetree/bindings/input/elan_i2c.txt
··· 13 13 pinctrl binding [1]). 14 14 - vcc-supply: a phandle for the regulator supplying 3.3V power. 15 15 - elan,trackpoint: touchpad can support a trackpoint (boolean) 16 + - elan,clickpad: touchpad is a clickpad (the entire surface is a button) 17 + - elan,middle-button: touchpad has a physical middle button 18 + - elan,x_traces: number of antennas on the x axis 19 + - elan,y_traces: number of antennas on the y axis 20 + - some generic touchscreen properties [2]: 21 + * touchscreen-size-x 22 + * touchscreen-size-y 23 + * touchscreen-x-mm 24 + * touchscreen-y-mm 25 + 16 26 17 27 [0]: Documentation/devicetree/bindings/interrupt-controller/interrupts.txt 18 28 [1]: Documentation/devicetree/bindings/pinctrl/pinctrl-bindings.txt 29 + [2]: Documentation/devicetree/bindings/input/touchscreen/touchscreen.txt 19 30 20 31 Example: 21 32 &i2c1 {
+11 -11
drivers/hid/hid-quirks.c
··· 16 16 #include <linux/export.h> 17 17 #include <linux/slab.h> 18 18 #include <linux/mutex.h> 19 + #include <linux/input/elan-i2c-ids.h> 19 20 20 21 #include "hid-ids.h" 21 22 ··· 917 916 918 917 bool hid_ignore(struct hid_device *hdev) 919 918 { 919 + int i; 920 + 920 921 if (hdev->quirks & HID_QUIRK_NO_IGNORE) 921 922 return false; 922 923 if (hdev->quirks & HID_QUIRK_IGNORE) ··· 983 980 break; 984 981 case USB_VENDOR_ID_ELAN: 985 982 /* 986 - * Many Elan devices have a product id of 0x0401 and are handled 987 - * by the elan_i2c input driver. But the ACPI HID ELAN0800 dev 988 - * is not (and cannot be) handled by that driver -> 989 - * Ignore all 0x0401 devs except for the ELAN0800 dev. 983 + * Blacklist of everything that gets handled by the elan_i2c 984 + * input driver. This avoids disabling valid touchpads and 985 + * other ELAN devices. 990 986 */ 991 - if (hdev->product == 0x0401 && 992 - strncmp(hdev->name, "ELAN0800", 8) != 0) 993 - return true; 994 - /* Same with product id 0x0400 */ 995 - if (hdev->product == 0x0400 && 996 - strncmp(hdev->name, "QTEC0001", 8) != 0) 997 - return true; 987 + if ((hdev->product == 0x0401 || hdev->product == 0x0400)) 988 + for (i = 0; strlen(elan_acpi_id[i].id); ++i) 989 + if (!strncmp(hdev->name, elan_acpi_id[i].id, 990 + strlen(elan_acpi_id[i].id))) 991 + return true; 998 992 break; 999 993 } 1000 994
+22 -2
drivers/input/joydev.c
··· 808 808 static bool joydev_dev_is_absolute_mouse(struct input_dev *dev) 809 809 { 810 810 DECLARE_BITMAP(jd_scratch, KEY_CNT); 811 + bool ev_match = false; 811 812 812 813 BUILD_BUG_ON(ABS_CNT > KEY_CNT || EV_CNT > KEY_CNT); 813 814 ··· 827 826 * considered to be an absolute mouse if the following is 828 827 * true: 829 828 * 830 - * 1) Event types are exactly EV_ABS, EV_KEY and EV_SYN. 829 + * 1) Event types are exactly 830 + * EV_ABS, EV_KEY and EV_SYN 831 + * or 832 + * EV_ABS, EV_KEY, EV_SYN and EV_MSC 833 + * or 834 + * EV_ABS, EV_KEY, EV_SYN, EV_MSC and EV_REL. 831 835 * 2) Absolute events are exactly ABS_X and ABS_Y. 832 836 * 3) Keys are exactly BTN_LEFT, BTN_RIGHT and BTN_MIDDLE. 833 837 * 4) Device is not on "Amiga" bus. 834 838 */ 835 839 836 840 bitmap_zero(jd_scratch, EV_CNT); 841 + /* VMware VMMouse, HP ILO2 */ 837 842 __set_bit(EV_ABS, jd_scratch); 838 843 __set_bit(EV_KEY, jd_scratch); 839 844 __set_bit(EV_SYN, jd_scratch); 840 - if (!bitmap_equal(jd_scratch, dev->evbit, EV_CNT)) 845 + if (bitmap_equal(jd_scratch, dev->evbit, EV_CNT)) 846 + ev_match = true; 847 + 848 + /* HP ILO2, AMI BMC firmware */ 849 + __set_bit(EV_MSC, jd_scratch); 850 + if (bitmap_equal(jd_scratch, dev->evbit, EV_CNT)) 851 + ev_match = true; 852 + 853 + /* VMware Virtual USB Mouse, QEMU USB Tablet, ATEN BMC firmware */ 854 + __set_bit(EV_REL, jd_scratch); 855 + if (bitmap_equal(jd_scratch, dev->evbit, EV_CNT)) 856 + ev_match = true; 857 + 858 + if (!ev_match) 841 859 return false; 842 860 843 861 bitmap_zero(jd_scratch, ABS_CNT);
+4 -4
drivers/input/joystick/iforce/Kconfig
··· 14 14 module will be called iforce. 15 15 16 16 config JOYSTICK_IFORCE_USB 17 - bool "I-Force USB joysticks and wheels" 18 - depends on JOYSTICK_IFORCE && (JOYSTICK_IFORCE=m || USB=y) && USB 17 + tristate "I-Force USB joysticks and wheels" 18 + depends on JOYSTICK_IFORCE && USB 19 19 help 20 20 Say Y here if you have an I-Force joystick or steering wheel 21 21 connected to your USB port. 22 22 23 23 config JOYSTICK_IFORCE_232 24 - bool "I-Force Serial joysticks and wheels" 25 - depends on JOYSTICK_IFORCE && (JOYSTICK_IFORCE=m || SERIO=y) && SERIO 24 + tristate "I-Force Serial joysticks and wheels" 25 + depends on JOYSTICK_IFORCE && SERIO 26 26 help 27 27 Say Y here if you have an I-Force joystick or steering wheel 28 28 connected to your serial (COM) port.
+3 -4
drivers/input/joystick/iforce/Makefile
··· 5 5 # By Johann Deneux <johann.deneux@gmail.com> 6 6 # 7 7 8 - obj-$(CONFIG_JOYSTICK_IFORCE) += iforce.o 9 - 8 + obj-$(CONFIG_JOYSTICK_IFORCE) += iforce.o 10 9 iforce-y := iforce-ff.o iforce-main.o iforce-packets.o 11 - iforce-$(CONFIG_JOYSTICK_IFORCE_232) += iforce-serio.o 12 - iforce-$(CONFIG_JOYSTICK_IFORCE_USB) += iforce-usb.o 10 + obj-$(CONFIG_JOYSTICK_IFORCE_232) += iforce-serio.o 11 + obj-$(CONFIG_JOYSTICK_IFORCE_USB) += iforce-usb.o
+9 -9
drivers/input/joystick/iforce/iforce-ff.c
··· 372 372 } 373 373 374 374 switch (effect->u.periodic.waveform) { 375 - case FF_SQUARE: wave_code = 0x20; break; 376 - case FF_TRIANGLE: wave_code = 0x21; break; 377 - case FF_SINE: wave_code = 0x22; break; 378 - case FF_SAW_UP: wave_code = 0x23; break; 379 - case FF_SAW_DOWN: wave_code = 0x24; break; 380 - default: wave_code = 0x20; break; 375 + case FF_SQUARE: wave_code = 0x20; break; 376 + case FF_TRIANGLE: wave_code = 0x21; break; 377 + case FF_SINE: wave_code = 0x22; break; 378 + case FF_SAW_UP: wave_code = 0x23; break; 379 + case FF_SAW_DOWN: wave_code = 0x24; break; 380 + default: wave_code = 0x20; break; 381 381 } 382 382 383 383 if (!old || need_core(old, effect)) { ··· 476 476 int core_err = 0; 477 477 478 478 switch (effect->type) { 479 - case FF_SPRING: type = 0x40; break; 480 - case FF_DAMPER: type = 0x41; break; 481 - default: return -1; 479 + case FF_SPRING: type = 0x40; break; 480 + case FF_DAMPER: type = 0x41; break; 481 + default: return -1; 482 482 } 483 483 484 484 if (!old || need_condition_modifier(iforce, old, effect)) {
+57 -121
drivers/input/joystick/iforce/iforce-main.c
··· 9 9 /* 10 10 */ 11 11 12 + #include <asm/unaligned.h> 12 13 #include "iforce.h" 13 14 14 15 MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>, Johann Deneux <johann.deneux@gmail.com>"); 15 - MODULE_DESCRIPTION("USB/RS232 I-Force joysticks and wheels driver"); 16 + MODULE_DESCRIPTION("Core I-Force joysticks and wheels driver"); 16 17 MODULE_LICENSE("GPL"); 17 18 18 19 static signed short btn_joystick[] = ··· 56 55 { 0x05ef, 0x8888, "AVB Top Shot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //? 57 56 { 0x061c, 0xc0a4, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, //? 58 57 { 0x061c, 0xc084, "ACT LABS Force RS", btn_wheel, abs_wheel, ff_iforce }, 58 + { 0x06a3, 0xff04, "Saitek R440 Force Wheel", btn_wheel, abs_wheel, ff_iforce }, //? 59 59 { 0x06f8, 0x0001, "Guillemot Race Leader Force Feedback", btn_wheel, abs_wheel, ff_iforce }, //? 60 60 { 0x06f8, 0x0001, "Guillemot Jet Leader Force Feedback", btn_joystick, abs_joystick_rudder, ff_iforce }, 61 61 { 0x06f8, 0x0004, "Guillemot Force Feedback Racing Wheel", btn_wheel, abs_wheel, ff_iforce }, //? ··· 122 120 * Upload the effect 123 121 */ 124 122 switch (effect->type) { 123 + case FF_PERIODIC: 124 + ret = iforce_upload_periodic(iforce, effect, old); 125 + break; 125 126 126 - case FF_PERIODIC: 127 - ret = iforce_upload_periodic(iforce, effect, old); 128 - break; 127 + case FF_CONSTANT: 128 + ret = iforce_upload_constant(iforce, effect, old); 129 + break; 129 130 130 - case FF_CONSTANT: 131 - ret = iforce_upload_constant(iforce, effect, old); 132 - break; 131 + case FF_SPRING: 132 + case FF_DAMPER: 133 + ret = iforce_upload_condition(iforce, effect, old); 134 + break; 133 135 134 - case FF_SPRING: 135 - case FF_DAMPER: 136 - ret = iforce_upload_condition(iforce, effect, old); 137 - break; 138 - 139 - default: 140 - return -EINVAL; 136 + default: 137 + return -EINVAL; 141 138 } 142 139 143 140 if (ret == 0) { ··· 174 173 { 175 174 struct iforce *iforce = input_get_drvdata(dev); 176 175 177 - switch (iforce->bus) { 178 - #ifdef CONFIG_JOYSTICK_IFORCE_USB 179 - case IFORCE_USB: 180 - iforce->irq->dev = iforce->usbdev; 181 - if (usb_submit_urb(iforce->irq, GFP_KERNEL)) 182 - return -EIO; 183 - break; 184 - #endif 185 - } 176 + iforce->xport_ops->start_io(iforce); 186 177 187 178 if (test_bit(EV_FF, dev->evbit)) { 188 179 /* Enable force feedback */ ··· 207 214 !test_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags)); 208 215 } 209 216 210 - switch (iforce->bus) { 211 - #ifdef CONFIG_JOYSTICK_IFORCE_USB 212 - case IFORCE_USB: 213 - usb_kill_urb(iforce->irq); 214 - usb_kill_urb(iforce->out); 215 - usb_kill_urb(iforce->ctrl); 216 - break; 217 - #endif 218 - #ifdef CONFIG_JOYSTICK_IFORCE_232 219 - case IFORCE_232: 220 - //TODO: Wait for the last packets to be sent 221 - break; 222 - #endif 223 - } 217 + iforce->xport_ops->stop_io(iforce); 224 218 } 225 219 226 - int iforce_init_device(struct iforce *iforce) 220 + int iforce_init_device(struct device *parent, u16 bustype, 221 + struct iforce *iforce) 227 222 { 228 223 struct input_dev *input_dev; 229 224 struct ff_device *ff; 230 - unsigned char c[] = "CEOV"; 225 + u8 c[] = "CEOV"; 226 + u8 buf[IFORCE_MAX_LENGTH]; 227 + size_t len; 231 228 int i, error; 232 229 int ff_effects = 0; 233 230 ··· 235 252 * Input device fields. 236 253 */ 237 254 238 - switch (iforce->bus) { 239 - #ifdef CONFIG_JOYSTICK_IFORCE_USB 240 - case IFORCE_USB: 241 - input_dev->id.bustype = BUS_USB; 242 - input_dev->dev.parent = &iforce->usbdev->dev; 243 - break; 244 - #endif 245 - #ifdef CONFIG_JOYSTICK_IFORCE_232 246 - case IFORCE_232: 247 - input_dev->id.bustype = BUS_RS232; 248 - input_dev->dev.parent = &iforce->serio->dev; 249 - break; 250 - #endif 251 - } 255 + input_dev->id.bustype = bustype; 256 + input_dev->dev.parent = parent; 252 257 253 258 input_set_drvdata(input_dev, iforce); 254 259 ··· 261 290 */ 262 291 263 292 for (i = 0; i < 20; i++) 264 - if (!iforce_get_id_packet(iforce, "O")) 293 + if (!iforce_get_id_packet(iforce, 'O', buf, &len)) 265 294 break; 266 295 267 296 if (i == 20) { /* 5 seconds */ ··· 275 304 * Get device info. 276 305 */ 277 306 278 - if (!iforce_get_id_packet(iforce, "M")) 279 - input_dev->id.vendor = (iforce->edata[2] << 8) | iforce->edata[1]; 307 + if (!iforce_get_id_packet(iforce, 'M', buf, &len) || len < 3) 308 + input_dev->id.vendor = get_unaligned_le16(buf + 1); 280 309 else 281 310 dev_warn(&iforce->dev->dev, "Device does not respond to id packet M\n"); 282 311 283 - if (!iforce_get_id_packet(iforce, "P")) 284 - input_dev->id.product = (iforce->edata[2] << 8) | iforce->edata[1]; 312 + if (!iforce_get_id_packet(iforce, 'P', buf, &len) || len < 3) 313 + input_dev->id.product = get_unaligned_le16(buf + 1); 285 314 else 286 315 dev_warn(&iforce->dev->dev, "Device does not respond to id packet P\n"); 287 316 288 - if (!iforce_get_id_packet(iforce, "B")) 289 - iforce->device_memory.end = (iforce->edata[2] << 8) | iforce->edata[1]; 317 + if (!iforce_get_id_packet(iforce, 'B', buf, &len) || len < 3) 318 + iforce->device_memory.end = get_unaligned_le16(buf + 1); 290 319 else 291 320 dev_warn(&iforce->dev->dev, "Device does not respond to id packet B\n"); 292 321 293 - if (!iforce_get_id_packet(iforce, "N")) 294 - ff_effects = iforce->edata[1]; 322 + if (!iforce_get_id_packet(iforce, 'N', buf, &len) || len < 2) 323 + ff_effects = buf[1]; 295 324 else 296 325 dev_warn(&iforce->dev->dev, "Device does not respond to id packet N\n"); 297 326 ··· 307 336 */ 308 337 309 338 for (i = 0; c[i]; i++) 310 - if (!iforce_get_id_packet(iforce, c + i)) 311 - iforce_dump_packet(iforce, "info", iforce->ecmd, iforce->edata); 339 + if (!iforce_get_id_packet(iforce, c[i], buf, &len)) 340 + iforce_dump_packet(iforce, "info", 341 + (FF_CMD_QUERY & 0xff00) | len, buf); 312 342 313 343 /* 314 344 * Disable spring, enable force feedback. ··· 343 371 signed short t = iforce->type->abs[i]; 344 372 345 373 switch (t) { 374 + case ABS_X: 375 + case ABS_Y: 376 + case ABS_WHEEL: 377 + input_set_abs_params(input_dev, t, -1920, 1920, 16, 128); 378 + set_bit(t, input_dev->ffbit); 379 + break; 346 380 347 - case ABS_X: 348 - case ABS_Y: 349 - case ABS_WHEEL: 381 + case ABS_THROTTLE: 382 + case ABS_GAS: 383 + case ABS_BRAKE: 384 + input_set_abs_params(input_dev, t, 0, 255, 0, 0); 385 + break; 350 386 351 - input_set_abs_params(input_dev, t, -1920, 1920, 16, 128); 352 - set_bit(t, input_dev->ffbit); 353 - break; 387 + case ABS_RUDDER: 388 + input_set_abs_params(input_dev, t, -128, 127, 0, 0); 389 + break; 354 390 355 - case ABS_THROTTLE: 356 - case ABS_GAS: 357 - case ABS_BRAKE: 358 - 359 - input_set_abs_params(input_dev, t, 0, 255, 0, 0); 360 - break; 361 - 362 - case ABS_RUDDER: 363 - 364 - input_set_abs_params(input_dev, t, -128, 127, 0, 0); 365 - break; 366 - 367 - case ABS_HAT0X: 368 - case ABS_HAT0Y: 369 - case ABS_HAT1X: 370 - case ABS_HAT1Y: 371 - 372 - input_set_abs_params(input_dev, t, -1, 1, 0, 0); 373 - break; 391 + case ABS_HAT0X: 392 + case ABS_HAT0Y: 393 + case ABS_HAT1X: 394 + case ABS_HAT1Y: 395 + input_set_abs_params(input_dev, t, -1, 1, 0, 0); 396 + break; 374 397 } 375 398 } 376 399 ··· 398 431 fail: input_free_device(input_dev); 399 432 return error; 400 433 } 401 - 402 - static int __init iforce_init(void) 403 - { 404 - int err = 0; 405 - 406 - #ifdef CONFIG_JOYSTICK_IFORCE_USB 407 - err = usb_register(&iforce_usb_driver); 408 - if (err) 409 - return err; 410 - #endif 411 - #ifdef CONFIG_JOYSTICK_IFORCE_232 412 - err = serio_register_driver(&iforce_serio_drv); 413 - #ifdef CONFIG_JOYSTICK_IFORCE_USB 414 - if (err) 415 - usb_deregister(&iforce_usb_driver); 416 - #endif 417 - #endif 418 - return err; 419 - } 420 - 421 - static void __exit iforce_exit(void) 422 - { 423 - #ifdef CONFIG_JOYSTICK_IFORCE_USB 424 - usb_deregister(&iforce_usb_driver); 425 - #endif 426 - #ifdef CONFIG_JOYSTICK_IFORCE_232 427 - serio_unregister_driver(&iforce_serio_drv); 428 - #endif 429 - } 430 - 431 - module_init(iforce_init); 432 - module_exit(iforce_exit); 434 + EXPORT_SYMBOL(iforce_init_device);
+74 -149
drivers/input/joystick/iforce/iforce-packets.c
··· 9 9 /* 10 10 */ 11 11 12 + #include <asm/unaligned.h> 12 13 #include "iforce.h" 13 14 14 15 static struct { ··· 80 79 /* 81 80 * If necessary, start the transmission 82 81 */ 83 - switch (iforce->bus) { 82 + if (empty) 83 + iforce->xport_ops->xmit(iforce); 84 84 85 - #ifdef CONFIG_JOYSTICK_IFORCE_232 86 - case IFORCE_232: 87 - if (empty) 88 - iforce_serial_xmit(iforce); 89 - break; 90 - #endif 91 - #ifdef CONFIG_JOYSTICK_IFORCE_USB 92 - case IFORCE_USB: 93 - 94 - if (iforce->usbdev && empty && 95 - !test_and_set_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags)) { 96 - 97 - iforce_usb_xmit(iforce); 98 - } 99 - break; 100 - #endif 101 - } 102 85 return 0; 103 86 } 87 + EXPORT_SYMBOL(iforce_send_packet); 104 88 105 89 /* Start or stop an effect */ 106 90 int iforce_control_playback(struct iforce* iforce, u16 id, unsigned int value) ··· 119 133 return -1; 120 134 } 121 135 122 - void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data) 136 + static void iforce_report_hats_buttons(struct iforce *iforce, u8 *data) 123 137 { 124 138 struct input_dev *dev = iforce->dev; 125 139 int i; 126 - static int being_used = 0; 127 140 128 - if (being_used) 129 - dev_warn(&iforce->dev->dev, 130 - "re-entrant call to iforce_process %d\n", being_used); 131 - being_used++; 141 + input_report_abs(dev, ABS_HAT0X, iforce_hat_to_axis[data[6] >> 4].x); 142 + input_report_abs(dev, ABS_HAT0Y, iforce_hat_to_axis[data[6] >> 4].y); 132 143 133 - #ifdef CONFIG_JOYSTICK_IFORCE_232 134 - if (HI(iforce->expect_packet) == HI(cmd)) { 135 - iforce->expect_packet = 0; 136 - iforce->ecmd = cmd; 137 - memcpy(iforce->edata, data, IFORCE_MAX_LENGTH); 144 + for (i = 0; iforce->type->btn[i] >= 0; i++) 145 + input_report_key(dev, iforce->type->btn[i], 146 + data[(i >> 3) + 5] & (1 << (i & 7))); 147 + 148 + /* If there are untouched bits left, interpret them as the second hat */ 149 + if (i <= 8) { 150 + u8 btns = data[6]; 151 + 152 + if (test_bit(ABS_HAT1X, dev->absbit)) { 153 + if (btns & BIT(3)) 154 + input_report_abs(dev, ABS_HAT1X, -1); 155 + else if (btns & BIT(1)) 156 + input_report_abs(dev, ABS_HAT1X, 1); 157 + else 158 + input_report_abs(dev, ABS_HAT1X, 0); 159 + } 160 + 161 + if (test_bit(ABS_HAT1Y, dev->absbit)) { 162 + if (btns & BIT(0)) 163 + input_report_abs(dev, ABS_HAT1Y, -1); 164 + else if (btns & BIT(2)) 165 + input_report_abs(dev, ABS_HAT1Y, 1); 166 + else 167 + input_report_abs(dev, ABS_HAT1Y, 0); 168 + } 138 169 } 139 - #endif 140 - wake_up(&iforce->wait); 141 - 142 - if (!iforce->type) { 143 - being_used--; 144 - return; 145 - } 146 - 147 - switch (HI(cmd)) { 148 - 149 - case 0x01: /* joystick position data */ 150 - case 0x03: /* wheel position data */ 151 - if (HI(cmd) == 1) { 152 - input_report_abs(dev, ABS_X, (__s16) (((__s16)data[1] << 8) | data[0])); 153 - input_report_abs(dev, ABS_Y, (__s16) (((__s16)data[3] << 8) | data[2])); 154 - input_report_abs(dev, ABS_THROTTLE, 255 - data[4]); 155 - if (LO(cmd) >= 8 && test_bit(ABS_RUDDER ,dev->absbit)) 156 - input_report_abs(dev, ABS_RUDDER, (__s8)data[7]); 157 - } else { 158 - input_report_abs(dev, ABS_WHEEL, (__s16) (((__s16)data[1] << 8) | data[0])); 159 - input_report_abs(dev, ABS_GAS, 255 - data[2]); 160 - input_report_abs(dev, ABS_BRAKE, 255 - data[3]); 161 - } 162 - 163 - input_report_abs(dev, ABS_HAT0X, iforce_hat_to_axis[data[6] >> 4].x); 164 - input_report_abs(dev, ABS_HAT0Y, iforce_hat_to_axis[data[6] >> 4].y); 165 - 166 - for (i = 0; iforce->type->btn[i] >= 0; i++) 167 - input_report_key(dev, iforce->type->btn[i], data[(i >> 3) + 5] & (1 << (i & 7))); 168 - 169 - /* If there are untouched bits left, interpret them as the second hat */ 170 - if (i <= 8) { 171 - int btns = data[6]; 172 - if (test_bit(ABS_HAT1X, dev->absbit)) { 173 - if (btns & 8) input_report_abs(dev, ABS_HAT1X, -1); 174 - else if (btns & 2) input_report_abs(dev, ABS_HAT1X, 1); 175 - else input_report_abs(dev, ABS_HAT1X, 0); 176 - } 177 - if (test_bit(ABS_HAT1Y, dev->absbit)) { 178 - if (btns & 1) input_report_abs(dev, ABS_HAT1Y, -1); 179 - else if (btns & 4) input_report_abs(dev, ABS_HAT1Y, 1); 180 - else input_report_abs(dev, ABS_HAT1Y, 0); 181 - } 182 - } 183 - 184 - input_sync(dev); 185 - 186 - break; 187 - 188 - case 0x02: /* status report */ 189 - input_report_key(dev, BTN_DEAD, data[0] & 0x02); 190 - input_sync(dev); 191 - 192 - /* Check if an effect was just started or stopped */ 193 - i = data[1] & 0x7f; 194 - if (data[1] & 0x80) { 195 - if (!test_and_set_bit(FF_CORE_IS_PLAYED, iforce->core_effects[i].flags)) { 196 - /* Report play event */ 197 - input_report_ff_status(dev, i, FF_STATUS_PLAYING); 198 - } 199 - } else if (test_and_clear_bit(FF_CORE_IS_PLAYED, iforce->core_effects[i].flags)) { 200 - /* Report stop event */ 201 - input_report_ff_status(dev, i, FF_STATUS_STOPPED); 202 - } 203 - if (LO(cmd) > 3) { 204 - int j; 205 - for (j = 3; j < LO(cmd); j += 2) 206 - mark_core_as_ready(iforce, data[j] | (data[j+1]<<8)); 207 - } 208 - break; 209 - } 210 - being_used--; 211 170 } 212 171 213 - int iforce_get_id_packet(struct iforce *iforce, char *packet) 172 + void iforce_process_packet(struct iforce *iforce, 173 + u8 packet_id, u8 *data, size_t len) 214 174 { 215 - switch (iforce->bus) { 175 + struct input_dev *dev = iforce->dev; 176 + int i, j; 216 177 217 - case IFORCE_USB: { 218 - #ifdef CONFIG_JOYSTICK_IFORCE_USB 219 - int status; 178 + switch (packet_id) { 220 179 221 - iforce->cr.bRequest = packet[0]; 222 - iforce->ctrl->dev = iforce->usbdev; 180 + case 0x01: /* joystick position data */ 181 + input_report_abs(dev, ABS_X, 182 + (__s16) get_unaligned_le16(data)); 183 + input_report_abs(dev, ABS_Y, 184 + (__s16) get_unaligned_le16(data + 2)); 185 + input_report_abs(dev, ABS_THROTTLE, 255 - data[4]); 223 186 224 - status = usb_submit_urb(iforce->ctrl, GFP_KERNEL); 225 - if (status) { 226 - dev_err(&iforce->intf->dev, 227 - "usb_submit_urb failed %d\n", status); 228 - return -1; 229 - } 187 + if (len >= 8 && test_bit(ABS_RUDDER ,dev->absbit)) 188 + input_report_abs(dev, ABS_RUDDER, (__s8)data[7]); 230 189 231 - wait_event_interruptible_timeout(iforce->wait, 232 - iforce->ctrl->status != -EINPROGRESS, HZ); 190 + iforce_report_hats_buttons(iforce, data); 233 191 234 - if (iforce->ctrl->status) { 235 - dev_dbg(&iforce->intf->dev, 236 - "iforce->ctrl->status = %d\n", 237 - iforce->ctrl->status); 238 - usb_unlink_urb(iforce->ctrl); 239 - return -1; 240 - } 241 - #else 242 - printk(KERN_DEBUG "iforce_get_id_packet: iforce->bus = USB!\n"); 243 - #endif 244 - } 192 + input_sync(dev); 245 193 break; 246 194 247 - case IFORCE_232: 195 + case 0x03: /* wheel position data */ 196 + input_report_abs(dev, ABS_WHEEL, 197 + (__s16) get_unaligned_le16(data)); 198 + input_report_abs(dev, ABS_GAS, 255 - data[2]); 199 + input_report_abs(dev, ABS_BRAKE, 255 - data[3]); 248 200 249 - #ifdef CONFIG_JOYSTICK_IFORCE_232 250 - iforce->expect_packet = FF_CMD_QUERY; 251 - iforce_send_packet(iforce, FF_CMD_QUERY, packet); 201 + iforce_report_hats_buttons(iforce, data); 252 202 253 - wait_event_interruptible_timeout(iforce->wait, 254 - !iforce->expect_packet, HZ); 255 - 256 - if (iforce->expect_packet) { 257 - iforce->expect_packet = 0; 258 - return -1; 259 - } 260 - #else 261 - dev_err(&iforce->dev->dev, 262 - "iforce_get_id_packet: iforce->bus = SERIO!\n"); 263 - #endif 203 + input_sync(dev); 264 204 break; 265 205 266 - default: 267 - dev_err(&iforce->dev->dev, 268 - "iforce_get_id_packet: iforce->bus = %d\n", 269 - iforce->bus); 206 + case 0x02: /* status report */ 207 + input_report_key(dev, BTN_DEAD, data[0] & 0x02); 208 + input_sync(dev); 209 + 210 + /* Check if an effect was just started or stopped */ 211 + i = data[1] & 0x7f; 212 + if (data[1] & 0x80) { 213 + if (!test_and_set_bit(FF_CORE_IS_PLAYED, iforce->core_effects[i].flags)) { 214 + /* Report play event */ 215 + input_report_ff_status(dev, i, FF_STATUS_PLAYING); 216 + } 217 + } else if (test_and_clear_bit(FF_CORE_IS_PLAYED, iforce->core_effects[i].flags)) { 218 + /* Report stop event */ 219 + input_report_ff_status(dev, i, FF_STATUS_STOPPED); 220 + } 221 + 222 + for (j = 3; j < len; j += 2) 223 + mark_core_as_ready(iforce, get_unaligned_le16(data + j)); 224 + 270 225 break; 271 226 } 272 - 273 - return -(iforce->edata[0] != packet[0]); 274 227 } 275 - 228 + EXPORT_SYMBOL(iforce_process_packet);
+124 -37
drivers/input/joystick/iforce/iforce-serio.c
··· 9 9 /* 10 10 */ 11 11 12 + #include <linux/serio.h> 12 13 #include "iforce.h" 13 14 14 - void iforce_serial_xmit(struct iforce *iforce) 15 + struct iforce_serio { 16 + struct iforce iforce; 17 + 18 + struct serio *serio; 19 + int idx, pkt, len, id; 20 + u8 csum; 21 + u8 expect_packet; 22 + u8 cmd_response[IFORCE_MAX_LENGTH]; 23 + u8 cmd_response_len; 24 + u8 data_in[IFORCE_MAX_LENGTH]; 25 + }; 26 + 27 + static void iforce_serio_xmit(struct iforce *iforce) 15 28 { 29 + struct iforce_serio *iforce_serio = container_of(iforce, 30 + struct iforce_serio, 31 + iforce); 16 32 unsigned char cs; 17 33 int i; 18 34 unsigned long flags; ··· 49 33 50 34 cs = 0x2b; 51 35 52 - serio_write(iforce->serio, 0x2b); 36 + serio_write(iforce_serio->serio, 0x2b); 53 37 54 - serio_write(iforce->serio, iforce->xmit.buf[iforce->xmit.tail]); 38 + serio_write(iforce_serio->serio, iforce->xmit.buf[iforce->xmit.tail]); 55 39 cs ^= iforce->xmit.buf[iforce->xmit.tail]; 56 40 XMIT_INC(iforce->xmit.tail, 1); 57 41 58 42 for (i=iforce->xmit.buf[iforce->xmit.tail]; i >= 0; --i) { 59 - serio_write(iforce->serio, iforce->xmit.buf[iforce->xmit.tail]); 43 + serio_write(iforce_serio->serio, 44 + iforce->xmit.buf[iforce->xmit.tail]); 60 45 cs ^= iforce->xmit.buf[iforce->xmit.tail]; 61 46 XMIT_INC(iforce->xmit.tail, 1); 62 47 } 63 48 64 - serio_write(iforce->serio, cs); 49 + serio_write(iforce_serio->serio, cs); 65 50 66 51 if (test_and_clear_bit(IFORCE_XMIT_AGAIN, iforce->xmit_flags)) 67 52 goto again; ··· 72 55 spin_unlock_irqrestore(&iforce->xmit_lock, flags); 73 56 } 74 57 58 + static int iforce_serio_get_id(struct iforce *iforce, u8 id, 59 + u8 *response_data, size_t *response_len) 60 + { 61 + struct iforce_serio *iforce_serio = container_of(iforce, 62 + struct iforce_serio, 63 + iforce); 64 + 65 + iforce_serio->expect_packet = HI(FF_CMD_QUERY); 66 + iforce_serio->cmd_response_len = 0; 67 + 68 + iforce_send_packet(iforce, FF_CMD_QUERY, &id); 69 + 70 + wait_event_interruptible_timeout(iforce->wait, 71 + !iforce_serio->expect_packet, HZ); 72 + 73 + if (iforce_serio->expect_packet) { 74 + iforce_serio->expect_packet = 0; 75 + return -ETIMEDOUT; 76 + } 77 + 78 + if (iforce_serio->cmd_response[0] != id) 79 + return -EIO; 80 + 81 + memcpy(response_data, iforce_serio->cmd_response, 82 + iforce_serio->cmd_response_len); 83 + *response_len = iforce_serio->cmd_response_len; 84 + 85 + return 0; 86 + } 87 + 88 + static int iforce_serio_start_io(struct iforce *iforce) 89 + { 90 + /* No special handling required */ 91 + return 0; 92 + } 93 + 94 + static void iforce_serio_stop_io(struct iforce *iforce) 95 + { 96 + //TODO: Wait for the last packets to be sent 97 + } 98 + 99 + static const struct iforce_xport_ops iforce_serio_xport_ops = { 100 + .xmit = iforce_serio_xmit, 101 + .get_id = iforce_serio_get_id, 102 + .start_io = iforce_serio_start_io, 103 + .stop_io = iforce_serio_stop_io, 104 + }; 105 + 75 106 static void iforce_serio_write_wakeup(struct serio *serio) 76 107 { 77 108 struct iforce *iforce = serio_get_drvdata(serio); 78 109 79 - iforce_serial_xmit(iforce); 110 + iforce_serio_xmit(iforce); 80 111 } 81 112 82 113 static irqreturn_t iforce_serio_irq(struct serio *serio, 83 - unsigned char data, unsigned int flags) 114 + unsigned char data, unsigned int flags) 84 115 { 85 - struct iforce *iforce = serio_get_drvdata(serio); 116 + struct iforce_serio *iforce_serio = serio_get_drvdata(serio); 117 + struct iforce *iforce = &iforce_serio->iforce; 86 118 87 - if (!iforce->pkt) { 119 + if (!iforce_serio->pkt) { 88 120 if (data == 0x2b) 89 - iforce->pkt = 1; 121 + iforce_serio->pkt = 1; 90 122 goto out; 91 123 } 92 124 93 - if (!iforce->id) { 125 + if (!iforce_serio->id) { 94 126 if (data > 3 && data != 0xff) 95 - iforce->pkt = 0; 127 + iforce_serio->pkt = 0; 96 128 else 97 - iforce->id = data; 129 + iforce_serio->id = data; 98 130 goto out; 99 131 } 100 132 101 - if (!iforce->len) { 133 + if (!iforce_serio->len) { 102 134 if (data > IFORCE_MAX_LENGTH) { 103 - iforce->pkt = 0; 104 - iforce->id = 0; 135 + iforce_serio->pkt = 0; 136 + iforce_serio->id = 0; 105 137 } else { 106 - iforce->len = data; 138 + iforce_serio->len = data; 107 139 } 108 140 goto out; 109 141 } 110 142 111 - if (iforce->idx < iforce->len) { 112 - iforce->csum += iforce->data[iforce->idx++] = data; 143 + if (iforce_serio->idx < iforce_serio->len) { 144 + iforce_serio->data_in[iforce_serio->idx++] = data; 145 + iforce_serio->csum += data; 113 146 goto out; 114 147 } 115 148 116 - if (iforce->idx == iforce->len) { 117 - iforce_process_packet(iforce, (iforce->id << 8) | iforce->idx, iforce->data); 118 - iforce->pkt = 0; 119 - iforce->id = 0; 120 - iforce->len = 0; 121 - iforce->idx = 0; 122 - iforce->csum = 0; 149 + if (iforce_serio->idx == iforce_serio->len) { 150 + /* Handle command completion */ 151 + if (iforce_serio->expect_packet == iforce_serio->id) { 152 + iforce_serio->expect_packet = 0; 153 + memcpy(iforce_serio->cmd_response, 154 + iforce_serio->data_in, IFORCE_MAX_LENGTH); 155 + iforce_serio->cmd_response_len = iforce_serio->len; 156 + 157 + /* Signal that command is done */ 158 + wake_up(&iforce->wait); 159 + } else if (likely(iforce->type)) { 160 + iforce_process_packet(iforce, iforce_serio->id, 161 + iforce_serio->data_in, 162 + iforce_serio->len); 163 + } 164 + 165 + iforce_serio->pkt = 0; 166 + iforce_serio->id = 0; 167 + iforce_serio->len = 0; 168 + iforce_serio->idx = 0; 169 + iforce_serio->csum = 0; 123 170 } 124 171 out: 125 172 return IRQ_HANDLED; ··· 191 110 192 111 static int iforce_serio_connect(struct serio *serio, struct serio_driver *drv) 193 112 { 194 - struct iforce *iforce; 113 + struct iforce_serio *iforce_serio; 195 114 int err; 196 115 197 - iforce = kzalloc(sizeof(struct iforce), GFP_KERNEL); 198 - if (!iforce) 116 + iforce_serio = kzalloc(sizeof(*iforce_serio), GFP_KERNEL); 117 + if (!iforce_serio) 199 118 return -ENOMEM; 200 119 201 - iforce->bus = IFORCE_232; 202 - iforce->serio = serio; 120 + iforce_serio->iforce.xport_ops = &iforce_serio_xport_ops; 203 121 204 - serio_set_drvdata(serio, iforce); 122 + iforce_serio->serio = serio; 123 + serio_set_drvdata(serio, iforce_serio); 205 124 206 125 err = serio_open(serio, drv); 207 126 if (err) 208 127 goto fail1; 209 128 210 - err = iforce_init_device(iforce); 129 + err = iforce_init_device(&serio->dev, BUS_RS232, &iforce_serio->iforce); 211 130 if (err) 212 131 goto fail2; 213 132 ··· 215 134 216 135 fail2: serio_close(serio); 217 136 fail1: serio_set_drvdata(serio, NULL); 218 - kfree(iforce); 137 + kfree(iforce_serio); 219 138 return err; 220 139 } 221 140 222 141 static void iforce_serio_disconnect(struct serio *serio) 223 142 { 224 - struct iforce *iforce = serio_get_drvdata(serio); 143 + struct iforce_serio *iforce_serio = serio_get_drvdata(serio); 225 144 226 - input_unregister_device(iforce->dev); 145 + input_unregister_device(iforce_serio->iforce.dev); 227 146 serio_close(serio); 228 147 serio_set_drvdata(serio, NULL); 229 - kfree(iforce); 148 + kfree(iforce_serio); 230 149 } 231 150 232 151 static const struct serio_device_id iforce_serio_ids[] = { ··· 252 171 .connect = iforce_serio_connect, 253 172 .disconnect = iforce_serio_disconnect, 254 173 }; 174 + 175 + module_serio_driver(iforce_serio_drv); 176 + 177 + MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>, Johann Deneux <johann.deneux@gmail.com>"); 178 + MODULE_DESCRIPTION("RS232 I-Force joysticks and wheels driver"); 179 + MODULE_LICENSE("GPL");
+135 -57
drivers/input/joystick/iforce/iforce-usb.c
··· 9 9 /* 10 10 */ 11 11 12 + #include <linux/usb.h> 12 13 #include "iforce.h" 13 14 14 - void iforce_usb_xmit(struct iforce *iforce) 15 + struct iforce_usb { 16 + struct iforce iforce; 17 + 18 + struct usb_device *usbdev; 19 + struct usb_interface *intf; 20 + struct urb *irq, *out; 21 + 22 + u8 data_in[IFORCE_MAX_LENGTH] ____cacheline_aligned; 23 + u8 data_out[IFORCE_MAX_LENGTH] ____cacheline_aligned; 24 + }; 25 + 26 + static void __iforce_usb_xmit(struct iforce *iforce) 15 27 { 28 + struct iforce_usb *iforce_usb = container_of(iforce, struct iforce_usb, 29 + iforce); 16 30 int n, c; 17 31 unsigned long flags; 18 32 ··· 38 24 return; 39 25 } 40 26 41 - ((char *)iforce->out->transfer_buffer)[0] = iforce->xmit.buf[iforce->xmit.tail]; 27 + ((char *)iforce_usb->out->transfer_buffer)[0] = iforce->xmit.buf[iforce->xmit.tail]; 42 28 XMIT_INC(iforce->xmit.tail, 1); 43 29 n = iforce->xmit.buf[iforce->xmit.tail]; 44 30 XMIT_INC(iforce->xmit.tail, 1); 45 31 46 - iforce->out->transfer_buffer_length = n + 1; 47 - iforce->out->dev = iforce->usbdev; 32 + iforce_usb->out->transfer_buffer_length = n + 1; 33 + iforce_usb->out->dev = iforce_usb->usbdev; 48 34 49 35 /* Copy rest of data then */ 50 36 c = CIRC_CNT_TO_END(iforce->xmit.head, iforce->xmit.tail, XMIT_SIZE); 51 37 if (n < c) c=n; 52 38 53 - memcpy(iforce->out->transfer_buffer + 1, 39 + memcpy(iforce_usb->out->transfer_buffer + 1, 54 40 &iforce->xmit.buf[iforce->xmit.tail], 55 41 c); 56 42 if (n != c) { 57 - memcpy(iforce->out->transfer_buffer + 1 + c, 43 + memcpy(iforce_usb->out->transfer_buffer + 1 + c, 58 44 &iforce->xmit.buf[0], 59 45 n-c); 60 46 } 61 47 XMIT_INC(iforce->xmit.tail, n); 62 48 63 - if ( (n=usb_submit_urb(iforce->out, GFP_ATOMIC)) ) { 49 + if ( (n=usb_submit_urb(iforce_usb->out, GFP_ATOMIC)) ) { 64 50 clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags); 65 - dev_warn(&iforce->intf->dev, "usb_submit_urb failed %d\n", n); 51 + dev_warn(&iforce_usb->intf->dev, 52 + "usb_submit_urb failed %d\n", n); 66 53 } 67 54 68 55 /* The IFORCE_XMIT_RUNNING bit is not cleared here. That's intended. ··· 72 57 spin_unlock_irqrestore(&iforce->xmit_lock, flags); 73 58 } 74 59 60 + static void iforce_usb_xmit(struct iforce *iforce) 61 + { 62 + if (!test_and_set_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags)) 63 + __iforce_usb_xmit(iforce); 64 + } 65 + 66 + static int iforce_usb_get_id(struct iforce *iforce, u8 id, 67 + u8 *response_data, size_t *response_len) 68 + { 69 + struct iforce_usb *iforce_usb = container_of(iforce, struct iforce_usb, 70 + iforce); 71 + u8 *buf; 72 + int status; 73 + 74 + buf = kmalloc(IFORCE_MAX_LENGTH, GFP_KERNEL); 75 + if (!buf) 76 + return -ENOMEM; 77 + 78 + status = usb_control_msg(iforce_usb->usbdev, 79 + usb_rcvctrlpipe(iforce_usb->usbdev, 0), 80 + id, 81 + USB_TYPE_VENDOR | USB_DIR_IN | 82 + USB_RECIP_INTERFACE, 83 + 0, 0, buf, IFORCE_MAX_LENGTH, HZ); 84 + if (status < 0) { 85 + dev_err(&iforce_usb->intf->dev, 86 + "usb_submit_urb failed: %d\n", status); 87 + } else if (buf[0] != id) { 88 + status = -EIO; 89 + } else { 90 + memcpy(response_data, buf, status); 91 + *response_len = status; 92 + status = 0; 93 + } 94 + 95 + kfree(buf); 96 + return status; 97 + } 98 + 99 + static int iforce_usb_start_io(struct iforce *iforce) 100 + { 101 + struct iforce_usb *iforce_usb = container_of(iforce, struct iforce_usb, 102 + iforce); 103 + 104 + if (usb_submit_urb(iforce_usb->irq, GFP_KERNEL)) 105 + return -EIO; 106 + 107 + return 0; 108 + } 109 + 110 + static void iforce_usb_stop_io(struct iforce *iforce) 111 + { 112 + struct iforce_usb *iforce_usb = container_of(iforce, struct iforce_usb, 113 + iforce); 114 + 115 + usb_kill_urb(iforce_usb->irq); 116 + usb_kill_urb(iforce_usb->out); 117 + } 118 + 119 + static const struct iforce_xport_ops iforce_usb_xport_ops = { 120 + .xmit = iforce_usb_xmit, 121 + .get_id = iforce_usb_get_id, 122 + .start_io = iforce_usb_start_io, 123 + .stop_io = iforce_usb_stop_io, 124 + }; 125 + 75 126 static void iforce_usb_irq(struct urb *urb) 76 127 { 77 - struct iforce *iforce = urb->context; 78 - struct device *dev = &iforce->intf->dev; 128 + struct iforce_usb *iforce_usb = urb->context; 129 + struct iforce *iforce = &iforce_usb->iforce; 130 + struct device *dev = &iforce_usb->intf->dev; 79 131 int status; 80 132 81 133 switch (urb->status) { ··· 162 80 goto exit; 163 81 } 164 82 165 - iforce_process_packet(iforce, 166 - (iforce->data[0] << 8) | (urb->actual_length - 1), iforce->data + 1); 83 + iforce_process_packet(iforce, iforce_usb->data_in[0], 84 + iforce_usb->data_in + 1, urb->actual_length - 1); 167 85 168 86 exit: 169 - status = usb_submit_urb (urb, GFP_ATOMIC); 87 + status = usb_submit_urb(urb, GFP_ATOMIC); 170 88 if (status) 171 89 dev_err(dev, "%s - usb_submit_urb failed with result %d\n", 172 90 __func__, status); ··· 174 92 175 93 static void iforce_usb_out(struct urb *urb) 176 94 { 177 - struct iforce *iforce = urb->context; 95 + struct iforce_usb *iforce_usb = urb->context; 96 + struct iforce *iforce = &iforce_usb->iforce; 178 97 179 98 if (urb->status) { 180 99 clear_bit(IFORCE_XMIT_RUNNING, iforce->xmit_flags); 181 - dev_dbg(&iforce->intf->dev, "urb->status %d, exiting\n", 100 + dev_dbg(&iforce_usb->intf->dev, "urb->status %d, exiting\n", 182 101 urb->status); 183 102 return; 184 103 } 185 104 186 - iforce_usb_xmit(iforce); 105 + __iforce_usb_xmit(iforce); 187 106 188 - wake_up(&iforce->wait); 189 - } 190 - 191 - static void iforce_usb_ctrl(struct urb *urb) 192 - { 193 - struct iforce *iforce = urb->context; 194 - if (urb->status) return; 195 - iforce->ecmd = 0xff00 | urb->actual_length; 196 107 wake_up(&iforce->wait); 197 108 } 198 109 ··· 195 120 struct usb_device *dev = interface_to_usbdev(intf); 196 121 struct usb_host_interface *interface; 197 122 struct usb_endpoint_descriptor *epirq, *epout; 198 - struct iforce *iforce; 123 + struct iforce_usb *iforce_usb; 199 124 int err = -ENOMEM; 200 125 201 126 interface = intf->cur_altsetting; ··· 206 131 epirq = &interface->endpoint[0].desc; 207 132 epout = &interface->endpoint[1].desc; 208 133 209 - if (!(iforce = kzalloc(sizeof(struct iforce) + 32, GFP_KERNEL))) 134 + iforce_usb = kzalloc(sizeof(*iforce_usb), GFP_KERNEL); 135 + if (!iforce_usb) 210 136 goto fail; 211 137 212 - if (!(iforce->irq = usb_alloc_urb(0, GFP_KERNEL))) 138 + iforce_usb->irq = usb_alloc_urb(0, GFP_KERNEL); 139 + if (!iforce_usb->irq) 213 140 goto fail; 214 141 215 - if (!(iforce->out = usb_alloc_urb(0, GFP_KERNEL))) 142 + iforce_usb->out = usb_alloc_urb(0, GFP_KERNEL); 143 + if (!iforce_usb->out) 216 144 goto fail; 217 145 218 - if (!(iforce->ctrl = usb_alloc_urb(0, GFP_KERNEL))) 219 - goto fail; 146 + iforce_usb->iforce.xport_ops = &iforce_usb_xport_ops; 220 147 221 - iforce->bus = IFORCE_USB; 222 - iforce->usbdev = dev; 223 - iforce->intf = intf; 148 + iforce_usb->usbdev = dev; 149 + iforce_usb->intf = intf; 224 150 225 - iforce->cr.bRequestType = USB_TYPE_VENDOR | USB_DIR_IN | USB_RECIP_INTERFACE; 226 - iforce->cr.wIndex = 0; 227 - iforce->cr.wLength = cpu_to_le16(16); 151 + usb_fill_int_urb(iforce_usb->irq, dev, 152 + usb_rcvintpipe(dev, epirq->bEndpointAddress), 153 + iforce_usb->data_in, sizeof(iforce_usb->data_in), 154 + iforce_usb_irq, iforce_usb, epirq->bInterval); 228 155 229 - usb_fill_int_urb(iforce->irq, dev, usb_rcvintpipe(dev, epirq->bEndpointAddress), 230 - iforce->data, 16, iforce_usb_irq, iforce, epirq->bInterval); 156 + usb_fill_int_urb(iforce_usb->out, dev, 157 + usb_sndintpipe(dev, epout->bEndpointAddress), 158 + iforce_usb->data_out, sizeof(iforce_usb->data_out), 159 + iforce_usb_out, iforce_usb, epout->bInterval); 231 160 232 - usb_fill_int_urb(iforce->out, dev, usb_sndintpipe(dev, epout->bEndpointAddress), 233 - iforce + 1, 32, iforce_usb_out, iforce, epout->bInterval); 234 - 235 - usb_fill_control_urb(iforce->ctrl, dev, usb_rcvctrlpipe(dev, 0), 236 - (void*) &iforce->cr, iforce->edata, 16, iforce_usb_ctrl, iforce); 237 - 238 - err = iforce_init_device(iforce); 161 + err = iforce_init_device(&intf->dev, BUS_USB, &iforce_usb->iforce); 239 162 if (err) 240 163 goto fail; 241 164 242 - usb_set_intfdata(intf, iforce); 165 + usb_set_intfdata(intf, iforce_usb); 243 166 return 0; 244 167 245 168 fail: 246 - if (iforce) { 247 - usb_free_urb(iforce->irq); 248 - usb_free_urb(iforce->out); 249 - usb_free_urb(iforce->ctrl); 250 - kfree(iforce); 169 + if (iforce_usb) { 170 + usb_free_urb(iforce_usb->irq); 171 + usb_free_urb(iforce_usb->out); 172 + kfree(iforce_usb); 251 173 } 252 174 253 175 return err; ··· 252 180 253 181 static void iforce_usb_disconnect(struct usb_interface *intf) 254 182 { 255 - struct iforce *iforce = usb_get_intfdata(intf); 183 + struct iforce_usb *iforce_usb = usb_get_intfdata(intf); 256 184 257 185 usb_set_intfdata(intf, NULL); 258 186 259 - input_unregister_device(iforce->dev); 187 + input_unregister_device(iforce_usb->iforce.dev); 260 188 261 - usb_free_urb(iforce->irq); 262 - usb_free_urb(iforce->out); 263 - usb_free_urb(iforce->ctrl); 189 + usb_free_urb(iforce_usb->irq); 190 + usb_free_urb(iforce_usb->out); 264 191 265 - kfree(iforce); 192 + kfree(iforce_usb); 266 193 } 267 194 268 195 static const struct usb_device_id iforce_usb_ids[] = { ··· 273 202 { USB_DEVICE(0x05ef, 0x8888) }, /* AVB Top Shot FFB Racing Wheel */ 274 203 { USB_DEVICE(0x061c, 0xc0a4) }, /* ACT LABS Force RS */ 275 204 { USB_DEVICE(0x061c, 0xc084) }, /* ACT LABS Force RS */ 205 + { USB_DEVICE(0x06a3, 0xff04) }, /* Saitek R440 Force Wheel */ 276 206 { USB_DEVICE(0x06f8, 0x0001) }, /* Guillemot Race Leader Force Feedback */ 277 207 { USB_DEVICE(0x06f8, 0x0003) }, /* Guillemot Jet Leader Force Feedback */ 278 208 { USB_DEVICE(0x06f8, 0x0004) }, /* Guillemot Force Feedback Racing Wheel */ ··· 289 217 .disconnect = iforce_usb_disconnect, 290 218 .id_table = iforce_usb_ids, 291 219 }; 220 + 221 + module_usb_driver(iforce_usb_driver); 222 + 223 + MODULE_AUTHOR("Vojtech Pavlik <vojtech@ucw.cz>, Johann Deneux <johann.deneux@gmail.com>"); 224 + MODULE_DESCRIPTION("USB I-Force joysticks and wheels driver"); 225 + MODULE_LICENSE("GPL");
+21 -32
drivers/input/joystick/iforce/iforce.h
··· 14 14 #include <linux/input.h> 15 15 #include <linux/module.h> 16 16 #include <linux/spinlock.h> 17 - #include <linux/usb.h> 18 - #include <linux/serio.h> 19 17 #include <linux/circ_buf.h> 20 18 #include <linux/mutex.h> 21 19 ··· 25 27 26 28 27 29 #define IFORCE_MAX_LENGTH 16 28 - 29 - /* iforce::bus */ 30 - #define IFORCE_232 1 31 - #define IFORCE_USB 2 32 30 33 31 #define IFORCE_EFFECTS_MAX 32 34 32 ··· 75 81 signed short *ff; 76 82 }; 77 83 84 + struct iforce; 85 + 86 + struct iforce_xport_ops { 87 + void (*xmit)(struct iforce *iforce); 88 + int (*get_id)(struct iforce *iforce, u8 id, 89 + u8 *response_data, size_t *response_len); 90 + int (*start_io)(struct iforce *iforce); 91 + void (*stop_io)(struct iforce *iforce); 92 + }; 93 + 78 94 struct iforce { 79 95 struct input_dev *dev; /* Input device interface */ 80 96 struct iforce_device *type; 81 - int bus; 97 + const struct iforce_xport_ops *xport_ops; 82 98 83 - unsigned char data[IFORCE_MAX_LENGTH]; 84 - unsigned char edata[IFORCE_MAX_LENGTH]; 85 - u16 ecmd; 86 - u16 expect_packet; 87 - 88 - #ifdef CONFIG_JOYSTICK_IFORCE_232 89 - struct serio *serio; /* RS232 transfer */ 90 - int idx, pkt, len, id; 91 - unsigned char csum; 92 - #endif 93 - #ifdef CONFIG_JOYSTICK_IFORCE_USB 94 - struct usb_device *usbdev; /* USB transfer */ 95 - struct usb_interface *intf; 96 - struct urb *irq, *out, *ctrl; 97 - struct usb_ctrlrequest cr; 98 - #endif 99 99 spinlock_t xmit_lock; 100 100 /* Buffer used for asynchronous sending of bytes to the device */ 101 101 struct circ_buf xmit; ··· 115 127 /* Encode a time value */ 116 128 #define TIME_SCALE(a) (a) 117 129 130 + static inline int iforce_get_id_packet(struct iforce *iforce, u8 id, 131 + u8 *response_data, size_t *response_len) 132 + { 133 + return iforce->xport_ops->get_id(iforce, id, 134 + response_data, response_len); 135 + } 118 136 119 137 /* Public functions */ 120 - /* iforce-serio.c */ 121 - void iforce_serial_xmit(struct iforce *iforce); 122 - 123 - /* iforce-usb.c */ 124 - void iforce_usb_xmit(struct iforce *iforce); 125 - 126 138 /* iforce-main.c */ 127 - int iforce_init_device(struct iforce *iforce); 139 + int iforce_init_device(struct device *parent, u16 bustype, 140 + struct iforce *iforce); 128 141 129 142 /* iforce-packets.c */ 130 143 int iforce_control_playback(struct iforce*, u16 id, unsigned int); 131 - void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data); 144 + void iforce_process_packet(struct iforce *iforce, 145 + u8 packet_id, u8 *data, size_t len); 132 146 int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data); 133 147 void iforce_dump_packet(struct iforce *iforce, char *msg, u16 cmd, unsigned char *data); 134 - int iforce_get_id_packet(struct iforce *iforce, char *packet); 135 148 136 149 /* iforce-ff.c */ 137 150 int iforce_upload_periodic(struct iforce *, struct ff_effect *, struct ff_effect *);
+2 -4
drivers/input/keyboard/gpio_keys.c
··· 771 771 struct fwnode_handle *child = NULL; 772 772 struct gpio_keys_drvdata *ddata; 773 773 struct input_dev *input; 774 - size_t size; 775 774 int i, error; 776 775 int wakeup = 0; 777 776 ··· 780 781 return PTR_ERR(pdata); 781 782 } 782 783 783 - size = sizeof(struct gpio_keys_drvdata) + 784 - pdata->nbuttons * sizeof(struct gpio_button_data); 785 - ddata = devm_kzalloc(dev, size, GFP_KERNEL); 784 + ddata = devm_kzalloc(dev, struct_size(ddata, data, pdata->nbuttons), 785 + GFP_KERNEL); 786 786 if (!ddata) { 787 787 dev_err(dev, "failed to allocate state\n"); 788 788 return -ENOMEM;
+5 -5
drivers/input/keyboard/gpio_keys_polled.c
··· 165 165 pdata->rep = device_property_present(dev, "autorepeat"); 166 166 device_property_read_u32(dev, "poll-interval", &pdata->poll_interval); 167 167 168 + device_property_read_string(dev, "label", &pdata->name); 169 + 168 170 device_for_each_child_node(dev, child) { 169 171 if (fwnode_property_read_u32(child, "linux,code", 170 172 &button->code)) { ··· 234 232 struct gpio_keys_polled_dev *bdev; 235 233 struct input_polled_dev *poll_dev; 236 234 struct input_dev *input; 237 - size_t size; 238 235 int error; 239 236 int i; 240 237 ··· 248 247 return -EINVAL; 249 248 } 250 249 251 - size = sizeof(struct gpio_keys_polled_dev) + 252 - pdata->nbuttons * sizeof(struct gpio_keys_button_data); 253 - bdev = devm_kzalloc(dev, size, GFP_KERNEL); 250 + bdev = devm_kzalloc(dev, struct_size(bdev, data, pdata->nbuttons), 251 + GFP_KERNEL); 254 252 if (!bdev) { 255 253 dev_err(dev, "no memory for private data\n"); 256 254 return -ENOMEM; ··· 269 269 270 270 input = poll_dev->input; 271 271 272 - input->name = pdev->name; 272 + input->name = pdata->name ?: pdev->name; 273 273 input->phys = DRV_NAME"/input0"; 274 274 275 275 input->id.bustype = BUS_HOST;
+1 -3
drivers/input/keyboard/imx_keypad.c
··· 422 422 dev_get_platdata(&pdev->dev); 423 423 struct imx_keypad *keypad; 424 424 struct input_dev *input_dev; 425 - struct resource *res; 426 425 int irq, error, i, row, col; 427 426 428 427 if (!keymap_data && !pdev->dev.of_node) { ··· 454 455 timer_setup(&keypad->check_matrix_timer, 455 456 imx_keypad_check_for_events, 0); 456 457 457 - res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 458 - keypad->mmio_base = devm_ioremap_resource(&pdev->dev, res); 458 + keypad->mmio_base = devm_platform_ioremap_resource(pdev, 0); 459 459 if (IS_ERR(keypad->mmio_base)) 460 460 return PTR_ERR(keypad->mmio_base); 461 461
+1 -2
drivers/input/keyboard/tca8418_keypad.c
··· 266 266 struct tca8418_keypad *keypad_data; 267 267 struct input_dev *input; 268 268 u32 rows = 0, cols = 0; 269 - int error, row_shift, max_keys; 269 + int error, row_shift; 270 270 u8 reg; 271 271 272 272 /* Check i2c driver capabilities */ ··· 291 291 } 292 292 293 293 row_shift = get_count_order(cols); 294 - max_keys = rows << row_shift; 295 294 296 295 /* Allocate memory for keypad_data and input device */ 297 296 keypad_data = devm_kzalloc(dev, sizeof(*keypad_data), GFP_KERNEL);
+2 -9
drivers/input/misc/da9063_onkey.c
··· 13 13 #include <linux/regmap.h> 14 14 #include <linux/of.h> 15 15 #include <linux/mfd/da9063/core.h> 16 - #include <linux/mfd/da9063/pdata.h> 17 16 #include <linux/mfd/da9063/registers.h> 18 17 #include <linux/mfd/da9062/core.h> 19 18 #include <linux/mfd/da9062/registers.h> ··· 191 192 192 193 static int da9063_onkey_probe(struct platform_device *pdev) 193 194 { 194 - struct da9063 *da9063 = dev_get_drvdata(pdev->dev.parent); 195 - struct da9063_pdata *pdata = dev_get_platdata(da9063->dev); 196 195 struct da9063_onkey *onkey; 197 196 const struct of_device_id *match; 198 197 int irq; ··· 217 220 return -ENXIO; 218 221 } 219 222 220 - if (pdata) 221 - onkey->key_power = pdata->key_power; 222 - else 223 - onkey->key_power = 224 - !of_property_read_bool(pdev->dev.of_node, 225 - "dlg,disable-key-power"); 223 + onkey->key_power = !of_property_read_bool(pdev->dev.of_node, 224 + "dlg,disable-key-power"); 226 225 227 226 onkey->input = devm_input_allocate_device(&pdev->dev); 228 227 if (!onkey->input) {
+1
drivers/input/misc/max77650-onkey.c
··· 119 119 MODULE_DESCRIPTION("MAXIM 77650/77651 ONKEY driver"); 120 120 MODULE_AUTHOR("Bartosz Golaszewski <bgolaszewski@baylibre.com>"); 121 121 MODULE_LICENSE("GPL v2"); 122 + MODULE_ALIAS("platform:max77650-onkey");
+57 -65
drivers/input/mouse/elan_i2c_core.c
··· 34 34 #include <linux/completion.h> 35 35 #include <linux/of.h> 36 36 #include <linux/property.h> 37 + #include <linux/input/elan-i2c-ids.h> 37 38 #include <linux/regulator/consumer.h> 38 39 #include <asm/unaligned.h> 39 40 ··· 97 96 u8 max_baseline; 98 97 bool baseline_ready; 99 98 u8 clickpad; 99 + bool middle_button; 100 100 }; 101 101 102 102 static int elan_get_fwinfo(u16 ic_type, u16 *validpage_count, ··· 365 363 366 364 static int elan_query_device_parameters(struct elan_tp_data *data) 367 365 { 366 + struct i2c_client *client = data->client; 368 367 unsigned int x_traces, y_traces; 368 + u32 x_mm, y_mm; 369 369 u8 hw_x_res, hw_y_res; 370 370 int error; 371 371 372 - error = data->ops->get_max(data->client, &data->max_x, &data->max_y); 373 - if (error) 374 - return error; 372 + if (device_property_read_u32(&client->dev, 373 + "touchscreen-size-x", &data->max_x) || 374 + device_property_read_u32(&client->dev, 375 + "touchscreen-size-y", &data->max_y)) { 376 + error = data->ops->get_max(data->client, 377 + &data->max_x, 378 + &data->max_y); 379 + if (error) 380 + return error; 381 + } else { 382 + /* size is the maximum + 1 */ 383 + --data->max_x; 384 + --data->max_y; 385 + } 375 386 376 - error = data->ops->get_num_traces(data->client, &x_traces, &y_traces); 377 - if (error) 378 - return error; 379 - 387 + if (device_property_read_u32(&client->dev, 388 + "elan,x_traces", 389 + &x_traces) || 390 + device_property_read_u32(&client->dev, 391 + "elan,y_traces", 392 + &y_traces)) { 393 + error = data->ops->get_num_traces(data->client, 394 + &x_traces, &y_traces); 395 + if (error) 396 + return error; 397 + } 380 398 data->width_x = data->max_x / x_traces; 381 399 data->width_y = data->max_y / y_traces; 382 400 383 - error = data->ops->get_resolution(data->client, &hw_x_res, &hw_y_res); 384 - if (error) 385 - return error; 401 + if (device_property_read_u32(&client->dev, 402 + "touchscreen-x-mm", &x_mm) || 403 + device_property_read_u32(&client->dev, 404 + "touchscreen-y-mm", &y_mm)) { 405 + error = data->ops->get_resolution(data->client, 406 + &hw_x_res, &hw_y_res); 407 + if (error) 408 + return error; 386 409 387 - data->x_res = elan_convert_resolution(hw_x_res); 388 - data->y_res = elan_convert_resolution(hw_y_res); 410 + data->x_res = elan_convert_resolution(hw_x_res); 411 + data->y_res = elan_convert_resolution(hw_y_res); 412 + } else { 413 + data->x_res = (data->max_x + 1) / x_mm; 414 + data->y_res = (data->max_y + 1) / y_mm; 415 + } 416 + 417 + if (device_property_read_bool(&client->dev, "elan,clickpad")) 418 + data->clickpad = 1; 419 + 420 + if (device_property_read_bool(&client->dev, "elan,middle-button")) 421 + data->middle_button = true; 389 422 390 423 return 0; 391 424 } ··· 960 923 finger_data += ETP_FINGER_DATA_LEN; 961 924 } 962 925 963 - input_report_key(input, BTN_LEFT, tp_info & 0x01); 964 - input_report_key(input, BTN_RIGHT, tp_info & 0x02); 926 + input_report_key(input, BTN_LEFT, tp_info & BIT(0)); 927 + input_report_key(input, BTN_MIDDLE, tp_info & BIT(2)); 928 + input_report_key(input, BTN_RIGHT, tp_info & BIT(1)); 965 929 input_report_abs(input, ABS_DISTANCE, hover_event != 0); 966 930 input_mt_report_pointer_emulation(input, true); 967 931 input_sync(input); ··· 1096 1058 1097 1059 __set_bit(EV_ABS, input->evbit); 1098 1060 __set_bit(INPUT_PROP_POINTER, input->propbit); 1099 - if (data->clickpad) 1061 + if (data->clickpad) { 1100 1062 __set_bit(INPUT_PROP_BUTTONPAD, input->propbit); 1101 - else 1063 + } else { 1102 1064 __set_bit(BTN_RIGHT, input->keybit); 1065 + if (data->middle_button) 1066 + __set_bit(BTN_MIDDLE, input->keybit); 1067 + } 1103 1068 __set_bit(BTN_LEFT, input->keybit); 1104 1069 1105 1070 /* Set up ST parameters */ ··· 1373 1332 MODULE_DEVICE_TABLE(i2c, elan_id); 1374 1333 1375 1334 #ifdef CONFIG_ACPI 1376 - static const struct acpi_device_id elan_acpi_id[] = { 1377 - { "ELAN0000", 0 }, 1378 - { "ELAN0100", 0 }, 1379 - { "ELAN0600", 0 }, 1380 - { "ELAN0601", 0 }, 1381 - { "ELAN0602", 0 }, 1382 - { "ELAN0603", 0 }, 1383 - { "ELAN0604", 0 }, 1384 - { "ELAN0605", 0 }, 1385 - { "ELAN0606", 0 }, 1386 - { "ELAN0607", 0 }, 1387 - { "ELAN0608", 0 }, 1388 - { "ELAN0609", 0 }, 1389 - { "ELAN060B", 0 }, 1390 - { "ELAN060C", 0 }, 1391 - { "ELAN060F", 0 }, 1392 - { "ELAN0610", 0 }, 1393 - { "ELAN0611", 0 }, 1394 - { "ELAN0612", 0 }, 1395 - { "ELAN0615", 0 }, 1396 - { "ELAN0616", 0 }, 1397 - { "ELAN0617", 0 }, 1398 - { "ELAN0618", 0 }, 1399 - { "ELAN0619", 0 }, 1400 - { "ELAN061A", 0 }, 1401 - { "ELAN061B", 0 }, 1402 - { "ELAN061C", 0 }, 1403 - { "ELAN061D", 0 }, 1404 - { "ELAN061E", 0 }, 1405 - { "ELAN061F", 0 }, 1406 - { "ELAN0620", 0 }, 1407 - { "ELAN0621", 0 }, 1408 - { "ELAN0622", 0 }, 1409 - { "ELAN0623", 0 }, 1410 - { "ELAN0624", 0 }, 1411 - { "ELAN0625", 0 }, 1412 - { "ELAN0626", 0 }, 1413 - { "ELAN0627", 0 }, 1414 - { "ELAN0628", 0 }, 1415 - { "ELAN0629", 0 }, 1416 - { "ELAN062A", 0 }, 1417 - { "ELAN062B", 0 }, 1418 - { "ELAN062C", 0 }, 1419 - { "ELAN062D", 0 }, 1420 - { "ELAN0631", 0 }, 1421 - { "ELAN0632", 0 }, 1422 - { "ELAN1000", 0 }, 1423 - { } 1424 - }; 1425 1335 MODULE_DEVICE_TABLE(acpi, elan_acpi_id); 1426 1336 #endif 1427 1337
+171 -151
drivers/input/mouse/elantech.c
··· 227 227 } 228 228 229 229 /* 230 + * Advertise INPUT_PROP_BUTTONPAD for clickpads. The testing of bit 12 in 231 + * fw_version for this is based on the following fw_version & caps table: 232 + * 233 + * Laptop-model: fw_version: caps: buttons: 234 + * Acer S3 0x461f00 10, 13, 0e clickpad 235 + * Acer S7-392 0x581f01 50, 17, 0d clickpad 236 + * Acer V5-131 0x461f02 01, 16, 0c clickpad 237 + * Acer V5-551 0x461f00 ? clickpad 238 + * Asus K53SV 0x450f01 78, 15, 0c 2 hw buttons 239 + * Asus G46VW 0x460f02 00, 18, 0c 2 hw buttons 240 + * Asus G750JX 0x360f00 00, 16, 0c 2 hw buttons 241 + * Asus TP500LN 0x381f17 10, 14, 0e clickpad 242 + * Asus X750JN 0x381f17 10, 14, 0e clickpad 243 + * Asus UX31 0x361f00 20, 15, 0e clickpad 244 + * Asus UX32VD 0x361f02 00, 15, 0e clickpad 245 + * Avatar AVIU-145A2 0x361f00 ? clickpad 246 + * Fujitsu CELSIUS H760 0x570f02 40, 14, 0c 3 hw buttons (**) 247 + * Fujitsu CELSIUS H780 0x5d0f02 41, 16, 0d 3 hw buttons (**) 248 + * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons 249 + * Fujitsu LIFEBOOK E546 0x470f00 50, 12, 09 2 hw buttons 250 + * Fujitsu LIFEBOOK E547 0x470f00 50, 12, 09 2 hw buttons 251 + * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons 252 + * Fujitsu LIFEBOOK E557 0x570f01 40, 14, 0c 2 hw buttons 253 + * Fujitsu T725 0x470f01 05, 12, 09 2 hw buttons 254 + * Fujitsu H730 0x570f00 c0, 14, 0c 3 hw buttons (**) 255 + * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons 256 + * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*) 257 + * Lenovo L530 0x350f02 b9, 15, 0c 2 hw buttons (*) 258 + * Samsung NF210 0x150b00 78, 14, 0a 2 hw buttons 259 + * Samsung NP770Z5E 0x575f01 10, 15, 0f clickpad 260 + * Samsung NP700Z5B 0x361f06 21, 15, 0f clickpad 261 + * Samsung NP900X3E-A02 0x575f03 ? clickpad 262 + * Samsung NP-QX410 0x851b00 19, 14, 0c clickpad 263 + * Samsung RC512 0x450f00 08, 15, 0c 2 hw buttons 264 + * Samsung RF710 0x450f00 ? 2 hw buttons 265 + * System76 Pangolin 0x250f01 ? 2 hw buttons 266 + * (*) + 3 trackpoint buttons 267 + * (**) + 0 trackpoint buttons 268 + * Note: Lenovo L430 and Lenovo L530 have the same fw_version/caps 269 + */ 270 + static inline int elantech_is_buttonpad(struct elantech_device_info *info) 271 + { 272 + return info->fw_version & 0x001000; 273 + } 274 + 275 + /* 230 276 * Interpret complete data packets and report absolute mode input events for 231 277 * hardware version 1. (4 byte packets) 232 278 */ ··· 569 523 input_report_key(dev, BTN_TOOL_TRIPLETAP, fingers == 3); 570 524 571 525 /* For clickpads map both buttons to BTN_LEFT */ 572 - if (etd->info.fw_version & 0x001000) 526 + if (elantech_is_buttonpad(&etd->info)) 573 527 input_report_key(dev, BTN_LEFT, packet[0] & 0x03); 574 528 else 575 529 psmouse_report_standard_buttons(dev, packet[0]); ··· 587 541 unsigned char *packet = psmouse->packet; 588 542 589 543 /* For clickpads map both buttons to BTN_LEFT */ 590 - if (etd->info.fw_version & 0x001000) 544 + if (elantech_is_buttonpad(&etd->info)) 591 545 input_report_key(dev, BTN_LEFT, packet[0] & 0x03); 592 546 else 593 547 psmouse_report_standard_buttons(dev, packet[0]); ··· 1037 991 return rc; 1038 992 } 1039 993 1040 - static int elantech_set_range(struct psmouse *psmouse, 1041 - unsigned int *x_min, unsigned int *y_min, 1042 - unsigned int *x_max, unsigned int *y_max, 1043 - unsigned int *width) 1044 - { 1045 - struct elantech_data *etd = psmouse->private; 1046 - struct elantech_device_info *info = &etd->info; 1047 - unsigned char param[3]; 1048 - unsigned char traces; 1049 - 1050 - switch (info->hw_version) { 1051 - case 1: 1052 - *x_min = ETP_XMIN_V1; 1053 - *y_min = ETP_YMIN_V1; 1054 - *x_max = ETP_XMAX_V1; 1055 - *y_max = ETP_YMAX_V1; 1056 - break; 1057 - 1058 - case 2: 1059 - if (info->fw_version == 0x020800 || 1060 - info->fw_version == 0x020b00 || 1061 - info->fw_version == 0x020030) { 1062 - *x_min = ETP_XMIN_V2; 1063 - *y_min = ETP_YMIN_V2; 1064 - *x_max = ETP_XMAX_V2; 1065 - *y_max = ETP_YMAX_V2; 1066 - } else { 1067 - int i; 1068 - int fixed_dpi; 1069 - 1070 - i = (info->fw_version > 0x020800 && 1071 - info->fw_version < 0x020900) ? 1 : 2; 1072 - 1073 - if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 1074 - return -1; 1075 - 1076 - fixed_dpi = param[1] & 0x10; 1077 - 1078 - if (((info->fw_version >> 16) == 0x14) && fixed_dpi) { 1079 - if (info->send_cmd(psmouse, ETP_SAMPLE_QUERY, param)) 1080 - return -1; 1081 - 1082 - *x_max = (info->capabilities[1] - i) * param[1] / 2; 1083 - *y_max = (info->capabilities[2] - i) * param[2] / 2; 1084 - } else if (info->fw_version == 0x040216) { 1085 - *x_max = 819; 1086 - *y_max = 405; 1087 - } else if (info->fw_version == 0x040219 || info->fw_version == 0x040215) { 1088 - *x_max = 900; 1089 - *y_max = 500; 1090 - } else { 1091 - *x_max = (info->capabilities[1] - i) * 64; 1092 - *y_max = (info->capabilities[2] - i) * 64; 1093 - } 1094 - } 1095 - break; 1096 - 1097 - case 3: 1098 - if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 1099 - return -1; 1100 - 1101 - *x_max = (0x0f & param[0]) << 8 | param[1]; 1102 - *y_max = (0xf0 & param[0]) << 4 | param[2]; 1103 - break; 1104 - 1105 - case 4: 1106 - if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 1107 - return -1; 1108 - 1109 - *x_max = (0x0f & param[0]) << 8 | param[1]; 1110 - *y_max = (0xf0 & param[0]) << 4 | param[2]; 1111 - traces = info->capabilities[1]; 1112 - if ((traces < 2) || (traces > *x_max)) 1113 - return -1; 1114 - 1115 - *width = *x_max / (traces - 1); 1116 - break; 1117 - } 1118 - 1119 - return 0; 1120 - } 1121 - 1122 994 /* 1123 995 * (value from firmware) * 10 + 790 = dpi 1124 996 * we also have to convert dpi to dots/mm (*10/254 to avoid floating point) ··· 1063 1099 return 0; 1064 1100 } 1065 1101 1066 - /* 1067 - * Advertise INPUT_PROP_BUTTONPAD for clickpads. The testing of bit 12 in 1068 - * fw_version for this is based on the following fw_version & caps table: 1069 - * 1070 - * Laptop-model: fw_version: caps: buttons: 1071 - * Acer S3 0x461f00 10, 13, 0e clickpad 1072 - * Acer S7-392 0x581f01 50, 17, 0d clickpad 1073 - * Acer V5-131 0x461f02 01, 16, 0c clickpad 1074 - * Acer V5-551 0x461f00 ? clickpad 1075 - * Asus K53SV 0x450f01 78, 15, 0c 2 hw buttons 1076 - * Asus G46VW 0x460f02 00, 18, 0c 2 hw buttons 1077 - * Asus G750JX 0x360f00 00, 16, 0c 2 hw buttons 1078 - * Asus TP500LN 0x381f17 10, 14, 0e clickpad 1079 - * Asus X750JN 0x381f17 10, 14, 0e clickpad 1080 - * Asus UX31 0x361f00 20, 15, 0e clickpad 1081 - * Asus UX32VD 0x361f02 00, 15, 0e clickpad 1082 - * Avatar AVIU-145A2 0x361f00 ? clickpad 1083 - * Fujitsu CELSIUS H760 0x570f02 40, 14, 0c 3 hw buttons (**) 1084 - * Fujitsu CELSIUS H780 0x5d0f02 41, 16, 0d 3 hw buttons (**) 1085 - * Fujitsu LIFEBOOK E544 0x470f00 d0, 12, 09 2 hw buttons 1086 - * Fujitsu LIFEBOOK E546 0x470f00 50, 12, 09 2 hw buttons 1087 - * Fujitsu LIFEBOOK E547 0x470f00 50, 12, 09 2 hw buttons 1088 - * Fujitsu LIFEBOOK E554 0x570f01 40, 14, 0c 2 hw buttons 1089 - * Fujitsu LIFEBOOK E557 0x570f01 40, 14, 0c 2 hw buttons 1090 - * Fujitsu T725 0x470f01 05, 12, 09 2 hw buttons 1091 - * Fujitsu H730 0x570f00 c0, 14, 0c 3 hw buttons (**) 1092 - * Gigabyte U2442 0x450f01 58, 17, 0c 2 hw buttons 1093 - * Lenovo L430 0x350f02 b9, 15, 0c 2 hw buttons (*) 1094 - * Lenovo L530 0x350f02 b9, 15, 0c 2 hw buttons (*) 1095 - * Samsung NF210 0x150b00 78, 14, 0a 2 hw buttons 1096 - * Samsung NP770Z5E 0x575f01 10, 15, 0f clickpad 1097 - * Samsung NP700Z5B 0x361f06 21, 15, 0f clickpad 1098 - * Samsung NP900X3E-A02 0x575f03 ? clickpad 1099 - * Samsung NP-QX410 0x851b00 19, 14, 0c clickpad 1100 - * Samsung RC512 0x450f00 08, 15, 0c 2 hw buttons 1101 - * Samsung RF710 0x450f00 ? 2 hw buttons 1102 - * System76 Pangolin 0x250f01 ? 2 hw buttons 1103 - * (*) + 3 trackpoint buttons 1104 - * (**) + 0 trackpoint buttons 1105 - * Note: Lenovo L430 and Lenovo L530 have the same fw_version/caps 1106 - */ 1107 1102 static void elantech_set_buttonpad_prop(struct psmouse *psmouse) 1108 1103 { 1109 1104 struct input_dev *dev = psmouse->dev; 1110 1105 struct elantech_data *etd = psmouse->private; 1111 1106 1112 - if (etd->info.fw_version & 0x001000) { 1107 + if (elantech_is_buttonpad(&etd->info)) { 1113 1108 __set_bit(INPUT_PROP_BUTTONPAD, dev->propbit); 1114 1109 __clear_bit(BTN_RIGHT, dev->keybit); 1115 1110 } ··· 1104 1181 { } 1105 1182 }; 1106 1183 1107 - static const char * const middle_button_pnp_ids[] = { 1108 - "LEN2131", /* ThinkPad P52 w/ NFC */ 1109 - "LEN2132", /* ThinkPad P52 */ 1110 - "LEN2133", /* ThinkPad P72 w/ NFC */ 1111 - "LEN2134", /* ThinkPad P72 */ 1112 - "LEN0407", 1113 - "LEN0408", 1114 - NULL 1115 - }; 1116 - 1117 1184 /* 1118 1185 * Set the appropriate event bits for the input subsystem 1119 1186 */ ··· 1112 1199 struct input_dev *dev = psmouse->dev; 1113 1200 struct elantech_data *etd = psmouse->private; 1114 1201 struct elantech_device_info *info = &etd->info; 1115 - unsigned int x_min = 0, y_min = 0, x_max = 0, y_max = 0, width = 0; 1116 - 1117 - if (elantech_set_range(psmouse, &x_min, &y_min, &x_max, &y_max, &width)) 1118 - return -1; 1202 + unsigned int x_min = info->x_min, y_min = info->y_min, 1203 + x_max = info->x_max, y_max = info->y_max, 1204 + width = info->width; 1119 1205 1120 1206 __set_bit(INPUT_PROP_POINTER, dev->propbit); 1121 1207 __set_bit(EV_KEY, dev->evbit); ··· 1122 1210 __clear_bit(EV_REL, dev->evbit); 1123 1211 1124 1212 __set_bit(BTN_LEFT, dev->keybit); 1125 - if (dmi_check_system(elantech_dmi_has_middle_button) || 1126 - psmouse_matches_pnp_id(psmouse, middle_button_pnp_ids)) 1213 + if (info->has_middle_button) 1127 1214 __set_bit(BTN_MIDDLE, dev->keybit); 1128 1215 __set_bit(BTN_RIGHT, dev->keybit); 1129 1216 ··· 1597 1686 struct elantech_device_info *info) 1598 1687 { 1599 1688 unsigned char param[3]; 1689 + unsigned char traces; 1600 1690 1601 1691 memset(info, 0, sizeof(*info)); 1602 1692 ··· 1666 1754 } 1667 1755 } 1668 1756 1757 + /* query range information */ 1758 + switch (info->hw_version) { 1759 + case 1: 1760 + info->x_min = ETP_XMIN_V1; 1761 + info->y_min = ETP_YMIN_V1; 1762 + info->x_max = ETP_XMAX_V1; 1763 + info->y_max = ETP_YMAX_V1; 1764 + break; 1765 + 1766 + case 2: 1767 + if (info->fw_version == 0x020800 || 1768 + info->fw_version == 0x020b00 || 1769 + info->fw_version == 0x020030) { 1770 + info->x_min = ETP_XMIN_V2; 1771 + info->y_min = ETP_YMIN_V2; 1772 + info->x_max = ETP_XMAX_V2; 1773 + info->y_max = ETP_YMAX_V2; 1774 + } else { 1775 + int i; 1776 + int fixed_dpi; 1777 + 1778 + i = (info->fw_version > 0x020800 && 1779 + info->fw_version < 0x020900) ? 1 : 2; 1780 + 1781 + if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 1782 + return -EINVAL; 1783 + 1784 + fixed_dpi = param[1] & 0x10; 1785 + 1786 + if (((info->fw_version >> 16) == 0x14) && fixed_dpi) { 1787 + if (info->send_cmd(psmouse, ETP_SAMPLE_QUERY, param)) 1788 + return -EINVAL; 1789 + 1790 + info->x_max = (info->capabilities[1] - i) * param[1] / 2; 1791 + info->y_max = (info->capabilities[2] - i) * param[2] / 2; 1792 + } else if (info->fw_version == 0x040216) { 1793 + info->x_max = 819; 1794 + info->y_max = 405; 1795 + } else if (info->fw_version == 0x040219 || info->fw_version == 0x040215) { 1796 + info->x_max = 900; 1797 + info->y_max = 500; 1798 + } else { 1799 + info->x_max = (info->capabilities[1] - i) * 64; 1800 + info->y_max = (info->capabilities[2] - i) * 64; 1801 + } 1802 + } 1803 + break; 1804 + 1805 + case 3: 1806 + if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 1807 + return -EINVAL; 1808 + 1809 + info->x_max = (0x0f & param[0]) << 8 | param[1]; 1810 + info->y_max = (0xf0 & param[0]) << 4 | param[2]; 1811 + break; 1812 + 1813 + case 4: 1814 + if (info->send_cmd(psmouse, ETP_FW_ID_QUERY, param)) 1815 + return -EINVAL; 1816 + 1817 + info->x_max = (0x0f & param[0]) << 8 | param[1]; 1818 + info->y_max = (0xf0 & param[0]) << 4 | param[2]; 1819 + traces = info->capabilities[1]; 1820 + if ((traces < 2) || (traces > info->x_max)) 1821 + return -EINVAL; 1822 + 1823 + info->width = info->x_max / (traces - 1); 1824 + 1825 + /* column number of traces */ 1826 + info->x_traces = traces; 1827 + 1828 + /* row number of traces */ 1829 + traces = info->capabilities[2]; 1830 + if ((traces >= 2) && (traces <= info->y_max)) 1831 + info->y_traces = traces; 1832 + 1833 + break; 1834 + } 1835 + 1836 + /* check for the middle button: DMI matching or new v4 firmwares */ 1837 + info->has_middle_button = dmi_check_system(elantech_dmi_has_middle_button) || 1838 + (ETP_NEW_IC_SMBUS_HOST_NOTIFY(info->fw_version) && 1839 + !elantech_is_buttonpad(info)); 1840 + 1669 1841 return 0; 1670 1842 } 1671 1843 ··· 1776 1780 * These are known to not be working properly as bits are missing 1777 1781 * in elan_i2c. 1778 1782 */ 1779 - "LEN2131", /* ThinkPad P52 w/ NFC */ 1780 - "LEN2132", /* ThinkPad P52 */ 1781 - "LEN2133", /* ThinkPad P72 w/ NFC */ 1782 - "LEN2134", /* ThinkPad P72 */ 1783 1783 NULL 1784 1784 }; 1785 1785 ··· 1783 1791 struct elantech_device_info *info, 1784 1792 bool leave_breadcrumbs) 1785 1793 { 1786 - const struct property_entry i2c_properties[] = { 1787 - PROPERTY_ENTRY_BOOL("elan,trackpoint"), 1788 - { }, 1789 - }; 1794 + struct property_entry i2c_props[11] = {}; 1790 1795 struct i2c_board_info smbus_board = { 1791 1796 I2C_BOARD_INFO("elan_i2c", 0x15), 1792 1797 .flags = I2C_CLIENT_HOST_NOTIFY, 1793 1798 }; 1799 + unsigned int idx = 0; 1800 + 1801 + smbus_board.properties = i2c_props; 1802 + 1803 + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-x", 1804 + info->x_max + 1); 1805 + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-size-y", 1806 + info->y_max + 1); 1807 + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-min-x", 1808 + info->x_min); 1809 + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-min-y", 1810 + info->y_min); 1811 + if (info->x_res) 1812 + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-x-mm", 1813 + (info->x_max + 1) / info->x_res); 1814 + if (info->y_res) 1815 + i2c_props[idx++] = PROPERTY_ENTRY_U32("touchscreen-y-mm", 1816 + (info->y_max + 1) / info->y_res); 1794 1817 1795 1818 if (info->has_trackpoint) 1796 - smbus_board.properties = i2c_properties; 1819 + i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,trackpoint"); 1820 + 1821 + if (info->has_middle_button) 1822 + i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,middle-button"); 1823 + 1824 + if (info->x_traces) 1825 + i2c_props[idx++] = PROPERTY_ENTRY_U32("elan,x_traces", 1826 + info->x_traces); 1827 + if (info->y_traces) 1828 + i2c_props[idx++] = PROPERTY_ENTRY_U32("elan,y_traces", 1829 + info->y_traces); 1830 + 1831 + if (elantech_is_buttonpad(info)) 1832 + i2c_props[idx++] = PROPERTY_ENTRY_BOOL("elan,clickpad"); 1797 1833 1798 1834 return psmouse_smbus_init(psmouse, &smbus_board, NULL, 0, false, 1799 1835 leave_breadcrumbs);
+8
drivers/input/mouse/elantech.h
··· 141 141 unsigned char debug; 142 142 unsigned char hw_version; 143 143 unsigned int fw_version; 144 + unsigned int x_min; 145 + unsigned int y_min; 146 + unsigned int x_max; 147 + unsigned int y_max; 144 148 unsigned int x_res; 145 149 unsigned int y_res; 150 + unsigned int x_traces; 151 + unsigned int y_traces; 152 + unsigned int width; 146 153 unsigned int bus; 147 154 bool paritycheck; 148 155 bool jumpy_cursor; ··· 157 150 bool crc_enabled; 158 151 bool set_hw_resolution; 159 152 bool has_trackpoint; 153 + bool has_middle_button; 160 154 int (*send_cmd)(struct psmouse *psmouse, unsigned char c, 161 155 unsigned char *param); 162 156 };
+1
drivers/input/mouse/synaptics.c
··· 173 173 "LEN0072", /* X1 Carbon Gen 5 (2017) - Elan/ALPS trackpoint */ 174 174 "LEN0073", /* X1 Carbon G5 (Elantech) */ 175 175 "LEN0092", /* X1 Carbon 6 */ 176 + "LEN0093", /* T480 */ 176 177 "LEN0096", /* X280 */ 177 178 "LEN0097", /* X280 -> ALPS trackpoint */ 178 179 "LEN200f", /* T450s */
+2 -4
drivers/input/rmi4/rmi_f12.c
··· 70 70 int pitch_y = 0; 71 71 int rx_receivers = 0; 72 72 int tx_receivers = 0; 73 - int sensor_flags = 0; 74 73 75 74 item = rmi_get_register_desc_item(&f12->control_reg_desc, 8); 76 75 if (!item) { ··· 125 126 offset += 2; 126 127 } 127 128 128 - if (rmi_register_desc_has_subpacket(item, 4)) { 129 - sensor_flags = buf[offset]; 129 + /* Skip over sensor flags */ 130 + if (rmi_register_desc_has_subpacket(item, 4)) 130 131 offset += 1; 131 - } 132 132 133 133 sensor->x_mm = (pitch_x * rx_receivers) >> 12; 134 134 sensor->y_mm = (pitch_y * tx_receivers) >> 12;
+12 -11
drivers/input/touchscreen/atmel_mxt_ts.c
··· 256 256 MXT_V4L_INPUT_MAX, 257 257 }; 258 258 259 - static const struct v4l2_file_operations mxt_video_fops = { 260 - .owner = THIS_MODULE, 261 - .open = v4l2_fh_open, 262 - .release = vb2_fop_release, 263 - .unlocked_ioctl = video_ioctl2, 264 - .read = vb2_fop_read, 265 - .mmap = vb2_fop_mmap, 266 - .poll = vb2_fop_poll, 267 - }; 268 - 269 259 enum mxt_suspend_mode { 270 260 MXT_SUSPEND_DEEP_SLEEP = 0, 271 261 MXT_SUSPEND_T9_CTRL = 1, ··· 1511 1521 } else if (config_crc == data->config_crc) { 1512 1522 dev_dbg(dev, "Config CRC 0x%06X: OK\n", 1513 1523 data->config_crc); 1514 - return 0; 1524 + ret = 0; 1525 + goto release_raw; 1515 1526 } else { 1516 1527 dev_info(dev, "Config CRC 0x%06X: does not match file 0x%06X\n", 1517 1528 data->config_crc, config_crc); ··· 2209 2218 } 2210 2219 2211 2220 #ifdef CONFIG_TOUCHSCREEN_ATMEL_MXT_T37 2221 + static const struct v4l2_file_operations mxt_video_fops = { 2222 + .owner = THIS_MODULE, 2223 + .open = v4l2_fh_open, 2224 + .release = vb2_fop_release, 2225 + .unlocked_ioctl = video_ioctl2, 2226 + .read = vb2_fop_read, 2227 + .mmap = vb2_fop_mmap, 2228 + .poll = vb2_fop_poll, 2229 + }; 2230 + 2212 2231 static u16 mxt_get_debug_value(struct mxt_data *data, unsigned int x, 2213 2232 unsigned int y) 2214 2233 {
+7 -11
drivers/input/touchscreen/edt-ft5x06.c
··· 27 27 #include <linux/gpio/consumer.h> 28 28 #include <linux/input/mt.h> 29 29 #include <linux/input/touchscreen.h> 30 + #include <asm/unaligned.h> 30 31 31 32 #define WORK_REGISTER_THRESHOLD 0x00 32 33 #define WORK_REGISTER_REPORT_RATE 0x08 ··· 229 228 230 229 for (i = 0; i < tsdata->max_support_points; i++) { 231 230 u8 *buf = &rdbuf[i * tplen + offset]; 232 - bool down; 233 231 234 232 type = buf[0] >> 6; 235 233 /* ignore Reserved events */ ··· 239 239 if (tsdata->version == EDT_M06 && type == TOUCH_EVENT_DOWN) 240 240 continue; 241 241 242 - x = ((buf[0] << 8) | buf[1]) & 0x0fff; 243 - y = ((buf[2] << 8) | buf[3]) & 0x0fff; 242 + x = get_unaligned_be16(buf) & 0x0fff; 243 + y = get_unaligned_be16(buf + 2) & 0x0fff; 244 244 /* The FT5x26 send the y coordinate first */ 245 245 if (tsdata->version == EV_FT) 246 246 swap(x, y); 247 247 248 248 id = (buf[2] >> 4) & 0x0f; 249 - down = type != TOUCH_EVENT_UP; 250 249 251 250 input_mt_slot(tsdata->input, id); 252 - input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, down); 253 - 254 - if (!down) 255 - continue; 256 - 257 - touchscreen_report_pos(tsdata->input, &tsdata->prop, x, y, 258 - true); 251 + if (input_mt_report_slot_state(tsdata->input, MT_TOOL_FINGER, 252 + type != TOUCH_EVENT_UP)) 253 + touchscreen_report_pos(tsdata->input, &tsdata->prop, 254 + x, y, true); 259 255 } 260 256 261 257 input_mt_report_pointer_emulation(tsdata->input, true);
+56 -15
drivers/input/touchscreen/eeti_ts.c
··· 28 28 struct input_dev *input; 29 29 struct gpio_desc *attn_gpio; 30 30 struct touchscreen_properties props; 31 + struct mutex mutex; 31 32 bool running; 32 33 }; 33 34 ··· 63 62 input_sync(eeti->input); 64 63 } 65 64 65 + static int eeti_ts_read(struct eeti_ts *eeti) 66 + { 67 + int len, error; 68 + char buf[6]; 69 + 70 + len = i2c_master_recv(eeti->client, buf, sizeof(buf)); 71 + if (len != sizeof(buf)) { 72 + error = len < 0 ? len : -EIO; 73 + dev_err(&eeti->client->dev, 74 + "failed to read touchscreen data: %d\n", 75 + error); 76 + return error; 77 + } 78 + 79 + /* Motion packet */ 80 + if (buf[0] & 0x80) 81 + eeti_ts_report_event(eeti, buf); 82 + 83 + return 0; 84 + } 85 + 66 86 static irqreturn_t eeti_ts_isr(int irq, void *dev_id) 67 87 { 68 88 struct eeti_ts *eeti = dev_id; 69 - int len; 70 89 int error; 71 - char buf[6]; 90 + 91 + mutex_lock(&eeti->mutex); 72 92 73 93 do { 74 - len = i2c_master_recv(eeti->client, buf, sizeof(buf)); 75 - if (len != sizeof(buf)) { 76 - error = len < 0 ? len : -EIO; 77 - dev_err(&eeti->client->dev, 78 - "failed to read touchscreen data: %d\n", 79 - error); 94 + /* 95 + * If we have attention GPIO, trust it. Otherwise we'll read 96 + * once and exit. We assume that in this case we are using 97 + * level triggered interrupt and it will get raised again 98 + * if/when there is more data. 99 + */ 100 + if (eeti->attn_gpio && 101 + !gpiod_get_value_cansleep(eeti->attn_gpio)) { 80 102 break; 81 103 } 82 104 83 - if (buf[0] & 0x80) { 84 - /* Motion packet */ 85 - eeti_ts_report_event(eeti, buf); 86 - } 87 - } while (eeti->running && 88 - eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio)); 105 + error = eeti_ts_read(eeti); 106 + if (error) 107 + break; 89 108 109 + } while (eeti->running && eeti->attn_gpio); 110 + 111 + mutex_unlock(&eeti->mutex); 90 112 return IRQ_HANDLED; 91 113 } 92 114 93 115 static void eeti_ts_start(struct eeti_ts *eeti) 94 116 { 117 + mutex_lock(&eeti->mutex); 118 + 95 119 eeti->running = true; 96 - wmb(); 97 120 enable_irq(eeti->client->irq); 121 + 122 + /* 123 + * Kick the controller in case we are using edge interrupt and 124 + * we missed our edge while interrupt was disabled. We expect 125 + * the attention GPIO to be wired in this case. 126 + */ 127 + if (eeti->attn_gpio && gpiod_get_value_cansleep(eeti->attn_gpio)) 128 + eeti_ts_read(eeti); 129 + 130 + mutex_unlock(&eeti->mutex); 98 131 } 99 132 100 133 static void eeti_ts_stop(struct eeti_ts *eeti) 101 134 { 135 + /* 136 + * Not locking here, just setting a flag and expect that the 137 + * interrupt thread will notice the flag eventually. 138 + */ 102 139 eeti->running = false; 103 140 wmb(); 104 141 disable_irq(eeti->client->irq); ··· 178 139 dev_err(dev, "failed to allocate driver data\n"); 179 140 return -ENOMEM; 180 141 } 142 + 143 + mutex_init(&eeti->mutex); 181 144 182 145 input = devm_input_allocate_device(dev); 183 146 if (!input) {
+2 -6
drivers/input/touchscreen/imx6ul_tsc.c
··· 364 364 struct device_node *np = pdev->dev.of_node; 365 365 struct imx6ul_tsc *tsc; 366 366 struct input_dev *input_dev; 367 - struct resource *tsc_mem; 368 - struct resource *adc_mem; 369 367 int err; 370 368 int tsc_irq; 371 369 int adc_irq; ··· 401 403 return err; 402 404 } 403 405 404 - tsc_mem = platform_get_resource(pdev, IORESOURCE_MEM, 0); 405 - tsc->tsc_regs = devm_ioremap_resource(&pdev->dev, tsc_mem); 406 + tsc->tsc_regs = devm_platform_ioremap_resource(pdev, 0); 406 407 if (IS_ERR(tsc->tsc_regs)) { 407 408 err = PTR_ERR(tsc->tsc_regs); 408 409 dev_err(&pdev->dev, "failed to remap tsc memory: %d\n", err); 409 410 return err; 410 411 } 411 412 412 - adc_mem = platform_get_resource(pdev, IORESOURCE_MEM, 1); 413 - tsc->adc_regs = devm_ioremap_resource(&pdev->dev, adc_mem); 413 + tsc->adc_regs = devm_platform_ioremap_resource(pdev, 1); 414 414 if (IS_ERR(tsc->adc_regs)) { 415 415 err = PTR_ERR(tsc->adc_regs); 416 416 dev_err(&pdev->dev, "failed to remap adc memory: %d\n", err);
-2
drivers/input/touchscreen/iqs5xx.c
··· 1056 1056 if (!iqs5xx) 1057 1057 return -ENOMEM; 1058 1058 1059 - dev_set_drvdata(&client->dev, iqs5xx); 1060 - 1061 1059 i2c_set_clientdata(client, iqs5xx); 1062 1060 iqs5xx->client = client; 1063 1061
+76
include/linux/input/elan-i2c-ids.h
··· 1 + /* 2 + * Elan I2C/SMBus Touchpad device whitelist 3 + * 4 + * Copyright (c) 2013 ELAN Microelectronics Corp. 5 + * 6 + * Author: æ維 (Duson Lin) <dusonlin@emc.com.tw> 7 + * Author: KT Liao <kt.liao@emc.com.tw> 8 + * Version: 1.6.3 9 + * 10 + * Based on cyapa driver: 11 + * copyright (c) 2011-2012 Cypress Semiconductor, Inc. 12 + * copyright (c) 2011-2012 Google, Inc. 13 + * 14 + * This program is free software; you can redistribute it and/or modify it 15 + * under the terms of the GNU General Public License version 2 as published 16 + * by the Free Software Foundation. 17 + * 18 + * Trademarks are the property of their respective owners. 19 + */ 20 + 21 + #ifndef __ELAN_I2C_IDS_H 22 + #define __ELAN_I2C_IDS_H 23 + 24 + #include <linux/mod_devicetable.h> 25 + 26 + static const struct acpi_device_id elan_acpi_id[] = { 27 + { "ELAN0000", 0 }, 28 + { "ELAN0100", 0 }, 29 + { "ELAN0600", 0 }, 30 + { "ELAN0601", 0 }, 31 + { "ELAN0602", 0 }, 32 + { "ELAN0603", 0 }, 33 + { "ELAN0604", 0 }, 34 + { "ELAN0605", 0 }, 35 + { "ELAN0606", 0 }, 36 + { "ELAN0607", 0 }, 37 + { "ELAN0608", 0 }, 38 + { "ELAN0609", 0 }, 39 + { "ELAN060B", 0 }, 40 + { "ELAN060C", 0 }, 41 + { "ELAN060F", 0 }, 42 + { "ELAN0610", 0 }, 43 + { "ELAN0611", 0 }, 44 + { "ELAN0612", 0 }, 45 + { "ELAN0615", 0 }, 46 + { "ELAN0616", 0 }, 47 + { "ELAN0617", 0 }, 48 + { "ELAN0618", 0 }, 49 + { "ELAN0619", 0 }, 50 + { "ELAN061A", 0 }, 51 + { "ELAN061B", 0 }, 52 + { "ELAN061C", 0 }, 53 + { "ELAN061D", 0 }, 54 + { "ELAN061E", 0 }, 55 + { "ELAN061F", 0 }, 56 + { "ELAN0620", 0 }, 57 + { "ELAN0621", 0 }, 58 + { "ELAN0622", 0 }, 59 + { "ELAN0623", 0 }, 60 + { "ELAN0624", 0 }, 61 + { "ELAN0625", 0 }, 62 + { "ELAN0626", 0 }, 63 + { "ELAN0627", 0 }, 64 + { "ELAN0628", 0 }, 65 + { "ELAN0629", 0 }, 66 + { "ELAN062A", 0 }, 67 + { "ELAN062B", 0 }, 68 + { "ELAN062C", 0 }, 69 + { "ELAN062D", 0 }, 70 + { "ELAN0631", 0 }, 71 + { "ELAN0632", 0 }, 72 + { "ELAN1000", 0 }, 73 + { } 74 + }; 75 + 76 + #endif /* __ELAN_I2C_IDS_H */