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

Configure Feed

Select the types of activity you want to include in your feed.

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

Pull input fixes from Dmitry Torokhov:

- joydev now implements a blacklist to avoid creating joystick nodes
for accelerometers found in composite devices such as PlaStation
controllers

- assorted driver fixes

* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dtor/input:
Input: ims-psu - check if CDC union descriptor is sane
Input: joydev - blacklist ds3/ds4/udraw motion sensors
Input: allow matching device IDs on property bits
Input: factor out and export input_device_id matching code
Input: goodix - poll the 'buffer status' bit before reading data
Input: axp20x-pek - fix module not auto-loading for axp221 pek
Input: tca8418 - enable interrupt after it has been requested
Input: stmfts - fix setting ABS_MT_POSITION_* maximum size
Input: ti_am335x_tsc - fix incorrect step config for 5 wire touchscreen
Input: synaptics - disable kernel tracking on SMBus devices

+200 -98
+39 -45
drivers/input/input.c
··· 933 933 } 934 934 EXPORT_SYMBOL(input_set_keycode); 935 935 936 + bool input_match_device_id(const struct input_dev *dev, 937 + const struct input_device_id *id) 938 + { 939 + if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) 940 + if (id->bustype != dev->id.bustype) 941 + return false; 942 + 943 + if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR) 944 + if (id->vendor != dev->id.vendor) 945 + return false; 946 + 947 + if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT) 948 + if (id->product != dev->id.product) 949 + return false; 950 + 951 + if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION) 952 + if (id->version != dev->id.version) 953 + return false; 954 + 955 + if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX) || 956 + !bitmap_subset(id->keybit, dev->keybit, KEY_MAX) || 957 + !bitmap_subset(id->relbit, dev->relbit, REL_MAX) || 958 + !bitmap_subset(id->absbit, dev->absbit, ABS_MAX) || 959 + !bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX) || 960 + !bitmap_subset(id->ledbit, dev->ledbit, LED_MAX) || 961 + !bitmap_subset(id->sndbit, dev->sndbit, SND_MAX) || 962 + !bitmap_subset(id->ffbit, dev->ffbit, FF_MAX) || 963 + !bitmap_subset(id->swbit, dev->swbit, SW_MAX) || 964 + !bitmap_subset(id->propbit, dev->propbit, INPUT_PROP_MAX)) { 965 + return false; 966 + } 967 + 968 + return true; 969 + } 970 + EXPORT_SYMBOL(input_match_device_id); 971 + 936 972 static const struct input_device_id *input_match_device(struct input_handler *handler, 937 973 struct input_dev *dev) 938 974 { 939 975 const struct input_device_id *id; 940 976 941 977 for (id = handler->id_table; id->flags || id->driver_info; id++) { 942 - 943 - if (id->flags & INPUT_DEVICE_ID_MATCH_BUS) 944 - if (id->bustype != dev->id.bustype) 945 - continue; 946 - 947 - if (id->flags & INPUT_DEVICE_ID_MATCH_VENDOR) 948 - if (id->vendor != dev->id.vendor) 949 - continue; 950 - 951 - if (id->flags & INPUT_DEVICE_ID_MATCH_PRODUCT) 952 - if (id->product != dev->id.product) 953 - continue; 954 - 955 - if (id->flags & INPUT_DEVICE_ID_MATCH_VERSION) 956 - if (id->version != dev->id.version) 957 - continue; 958 - 959 - if (!bitmap_subset(id->evbit, dev->evbit, EV_MAX)) 960 - continue; 961 - 962 - if (!bitmap_subset(id->keybit, dev->keybit, KEY_MAX)) 963 - continue; 964 - 965 - if (!bitmap_subset(id->relbit, dev->relbit, REL_MAX)) 966 - continue; 967 - 968 - if (!bitmap_subset(id->absbit, dev->absbit, ABS_MAX)) 969 - continue; 970 - 971 - if (!bitmap_subset(id->mscbit, dev->mscbit, MSC_MAX)) 972 - continue; 973 - 974 - if (!bitmap_subset(id->ledbit, dev->ledbit, LED_MAX)) 975 - continue; 976 - 977 - if (!bitmap_subset(id->sndbit, dev->sndbit, SND_MAX)) 978 - continue; 979 - 980 - if (!bitmap_subset(id->ffbit, dev->ffbit, FF_MAX)) 981 - continue; 982 - 983 - if (!bitmap_subset(id->swbit, dev->swbit, SW_MAX)) 984 - continue; 985 - 986 - if (!handler->match || handler->match(handler, dev)) 978 + if (input_match_device_id(dev, id) && 979 + (!handler->match || handler->match(handler, dev))) { 987 980 return id; 981 + } 988 982 } 989 983 990 984 return NULL;
+64 -6
drivers/input/joydev.c
··· 747 747 input_close_device(handle); 748 748 } 749 749 750 + /* 751 + * These codes are copied from from hid-ids.h, unfortunately there is no common 752 + * usb_ids/bt_ids.h header. 753 + */ 754 + #define USB_VENDOR_ID_SONY 0x054c 755 + #define USB_DEVICE_ID_SONY_PS3_CONTROLLER 0x0268 756 + #define USB_DEVICE_ID_SONY_PS4_CONTROLLER 0x05c4 757 + #define USB_DEVICE_ID_SONY_PS4_CONTROLLER_2 0x09cc 758 + #define USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE 0x0ba0 759 + 760 + #define USB_VENDOR_ID_THQ 0x20d6 761 + #define USB_DEVICE_ID_THQ_PS3_UDRAW 0xcb17 762 + 763 + #define ACCEL_DEV(vnd, prd) \ 764 + { \ 765 + .flags = INPUT_DEVICE_ID_MATCH_VENDOR | \ 766 + INPUT_DEVICE_ID_MATCH_PRODUCT | \ 767 + INPUT_DEVICE_ID_MATCH_PROPBIT, \ 768 + .vendor = (vnd), \ 769 + .product = (prd), \ 770 + .propbit = { BIT_MASK(INPUT_PROP_ACCELEROMETER) }, \ 771 + } 772 + 773 + static const struct input_device_id joydev_blacklist[] = { 774 + /* Avoid touchpads and touchscreens */ 775 + { 776 + .flags = INPUT_DEVICE_ID_MATCH_EVBIT | 777 + INPUT_DEVICE_ID_MATCH_KEYBIT, 778 + .evbit = { BIT_MASK(EV_KEY) }, 779 + .keybit = { [BIT_WORD(BTN_TOUCH)] = BIT_MASK(BTN_TOUCH) }, 780 + }, 781 + /* Avoid tablets, digitisers and similar devices */ 782 + { 783 + .flags = INPUT_DEVICE_ID_MATCH_EVBIT | 784 + INPUT_DEVICE_ID_MATCH_KEYBIT, 785 + .evbit = { BIT_MASK(EV_KEY) }, 786 + .keybit = { [BIT_WORD(BTN_DIGI)] = BIT_MASK(BTN_DIGI) }, 787 + }, 788 + /* Disable accelerometers on composite devices */ 789 + ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS3_CONTROLLER), 790 + ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER), 791 + ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_2), 792 + ACCEL_DEV(USB_VENDOR_ID_SONY, USB_DEVICE_ID_SONY_PS4_CONTROLLER_DONGLE), 793 + ACCEL_DEV(USB_VENDOR_ID_THQ, USB_DEVICE_ID_THQ_PS3_UDRAW), 794 + { /* sentinel */ } 795 + }; 796 + 797 + static bool joydev_dev_is_blacklisted(struct input_dev *dev) 798 + { 799 + const struct input_device_id *id; 800 + 801 + for (id = joydev_blacklist; id->flags; id++) { 802 + if (input_match_device_id(dev, id)) { 803 + dev_dbg(&dev->dev, 804 + "joydev: blacklisting '%s'\n", dev->name); 805 + return true; 806 + } 807 + } 808 + 809 + return false; 810 + } 811 + 750 812 static bool joydev_dev_is_absolute_mouse(struct input_dev *dev) 751 813 { 752 814 DECLARE_BITMAP(jd_scratch, KEY_CNT); ··· 869 807 870 808 static bool joydev_match(struct input_handler *handler, struct input_dev *dev) 871 809 { 872 - /* Avoid touchpads and touchscreens */ 873 - if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit)) 874 - return false; 875 - 876 - /* Avoid tablets, digitisers and similar devices */ 877 - if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_DIGI, dev->keybit)) 810 + /* Disable blacklisted devices */ 811 + if (joydev_dev_is_blacklisted(dev)) 878 812 return false; 879 813 880 814 /* Avoid absolute mice */
+17 -12
drivers/input/keyboard/tca8418_keypad.c
··· 234 234 static int tca8418_configure(struct tca8418_keypad *keypad_data, 235 235 u32 rows, u32 cols) 236 236 { 237 - int reg, error; 238 - 239 - /* Write config register, if this fails assume device not present */ 240 - error = tca8418_write_byte(keypad_data, REG_CFG, 241 - CFG_INT_CFG | CFG_OVR_FLOW_IEN | CFG_KE_IEN); 242 - if (error < 0) 243 - return -ENODEV; 244 - 237 + int reg, error = 0; 245 238 246 239 /* Assemble a mask for row and column registers */ 247 240 reg = ~(~0 << rows); ··· 250 257 error |= tca8418_write_byte(keypad_data, REG_DEBOUNCE_DIS2, reg >> 8); 251 258 error |= tca8418_write_byte(keypad_data, REG_DEBOUNCE_DIS3, reg >> 16); 252 259 260 + if (error) 261 + return error; 262 + 263 + error = tca8418_write_byte(keypad_data, REG_CFG, 264 + CFG_INT_CFG | CFG_OVR_FLOW_IEN | CFG_KE_IEN); 265 + 253 266 return error; 254 267 } 255 268 ··· 267 268 struct input_dev *input; 268 269 u32 rows = 0, cols = 0; 269 270 int error, row_shift, max_keys; 271 + u8 reg; 270 272 271 273 /* Check i2c driver capabilities */ 272 274 if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE)) { ··· 301 301 keypad_data->client = client; 302 302 keypad_data->row_shift = row_shift; 303 303 304 - /* Initialize the chip or fail if chip isn't present */ 305 - error = tca8418_configure(keypad_data, rows, cols); 306 - if (error < 0) 307 - return error; 304 + /* Read key lock register, if this fails assume device not present */ 305 + error = tca8418_read_byte(keypad_data, REG_KEY_LCK_EC, &reg); 306 + if (error) 307 + return -ENODEV; 308 308 309 309 /* Configure input device */ 310 310 input = devm_input_allocate_device(dev); ··· 339 339 client->irq, error); 340 340 return error; 341 341 } 342 + 343 + /* Initialize the chip */ 344 + error = tca8418_configure(keypad_data, rows, cols); 345 + if (error < 0) 346 + return error; 342 347 343 348 error = input_register_device(input); 344 349 if (error) {
+1 -1
drivers/input/misc/axp20x-pek.c
··· 403 403 }, 404 404 { /* sentinel */ } 405 405 }; 406 + MODULE_DEVICE_TABLE(platform, axp_pek_id_match); 406 407 407 408 static struct platform_driver axp20x_pek_driver = { 408 409 .probe = axp20x_pek_probe, ··· 418 417 MODULE_DESCRIPTION("axp20x Power Button"); 419 418 MODULE_AUTHOR("Carlo Caione <carlo@caione.org>"); 420 419 MODULE_LICENSE("GPL"); 421 - MODULE_ALIAS("platform:axp20x-pek");
+14 -2
drivers/input/misc/ims-pcu.c
··· 1635 1635 return NULL; 1636 1636 } 1637 1637 1638 - while (buflen > 0) { 1638 + while (buflen >= sizeof(*union_desc)) { 1639 1639 union_desc = (struct usb_cdc_union_desc *)buf; 1640 + 1641 + if (union_desc->bLength > buflen) { 1642 + dev_err(&intf->dev, "Too large descriptor\n"); 1643 + return NULL; 1644 + } 1640 1645 1641 1646 if (union_desc->bDescriptorType == USB_DT_CS_INTERFACE && 1642 1647 union_desc->bDescriptorSubType == USB_CDC_UNION_TYPE) { 1643 1648 dev_dbg(&intf->dev, "Found union header\n"); 1644 - return union_desc; 1649 + 1650 + if (union_desc->bLength >= sizeof(*union_desc)) 1651 + return union_desc; 1652 + 1653 + dev_err(&intf->dev, 1654 + "Union descriptor to short (%d vs %zd\n)", 1655 + union_desc->bLength, sizeof(*union_desc)); 1656 + return NULL; 1645 1657 } 1646 1658 1647 1659 buflen -= union_desc->bLength;
+1 -2
drivers/input/mouse/synaptics.c
··· 1709 1709 .sensor_pdata = { 1710 1710 .sensor_type = rmi_sensor_touchpad, 1711 1711 .axis_align.flip_y = true, 1712 - /* to prevent cursors jumps: */ 1713 - .kernel_tracking = true, 1712 + .kernel_tracking = false, 1714 1713 .topbuttonpad = topbuttonpad, 1715 1714 }, 1716 1715 .f30_data = {
+45 -24
drivers/input/touchscreen/goodix.c
··· 72 72 #define GOODIX_REG_CONFIG_DATA 0x8047 73 73 #define GOODIX_REG_ID 0x8140 74 74 75 + #define GOODIX_BUFFER_STATUS_READY BIT(7) 76 + #define GOODIX_BUFFER_STATUS_TIMEOUT 20 77 + 75 78 #define RESOLUTION_LOC 1 76 79 #define MAX_CONTACTS_LOC 5 77 80 #define TRIGGER_LOC 6 ··· 198 195 199 196 static int goodix_ts_read_input_report(struct goodix_ts_data *ts, u8 *data) 200 197 { 198 + unsigned long max_timeout; 201 199 int touch_num; 202 200 int error; 203 201 204 - error = goodix_i2c_read(ts->client, GOODIX_READ_COOR_ADDR, data, 205 - GOODIX_CONTACT_SIZE + 1); 206 - if (error) { 207 - dev_err(&ts->client->dev, "I2C transfer error: %d\n", error); 208 - return error; 209 - } 210 - 211 - if (!(data[0] & 0x80)) 212 - return -EAGAIN; 213 - 214 - touch_num = data[0] & 0x0f; 215 - if (touch_num > ts->max_touch_num) 216 - return -EPROTO; 217 - 218 - if (touch_num > 1) { 219 - data += 1 + GOODIX_CONTACT_SIZE; 220 - error = goodix_i2c_read(ts->client, 221 - GOODIX_READ_COOR_ADDR + 222 - 1 + GOODIX_CONTACT_SIZE, 223 - data, 224 - GOODIX_CONTACT_SIZE * (touch_num - 1)); 225 - if (error) 202 + /* 203 + * The 'buffer status' bit, which indicates that the data is valid, is 204 + * not set as soon as the interrupt is raised, but slightly after. 205 + * This takes around 10 ms to happen, so we poll for 20 ms. 206 + */ 207 + max_timeout = jiffies + msecs_to_jiffies(GOODIX_BUFFER_STATUS_TIMEOUT); 208 + do { 209 + error = goodix_i2c_read(ts->client, GOODIX_READ_COOR_ADDR, 210 + data, GOODIX_CONTACT_SIZE + 1); 211 + if (error) { 212 + dev_err(&ts->client->dev, "I2C transfer error: %d\n", 213 + error); 226 214 return error; 227 - } 215 + } 228 216 229 - return touch_num; 217 + if (data[0] & GOODIX_BUFFER_STATUS_READY) { 218 + touch_num = data[0] & 0x0f; 219 + if (touch_num > ts->max_touch_num) 220 + return -EPROTO; 221 + 222 + if (touch_num > 1) { 223 + data += 1 + GOODIX_CONTACT_SIZE; 224 + error = goodix_i2c_read(ts->client, 225 + GOODIX_READ_COOR_ADDR + 226 + 1 + GOODIX_CONTACT_SIZE, 227 + data, 228 + GOODIX_CONTACT_SIZE * 229 + (touch_num - 1)); 230 + if (error) 231 + return error; 232 + } 233 + 234 + return touch_num; 235 + } 236 + 237 + usleep_range(1000, 2000); /* Poll every 1 - 2 ms */ 238 + } while (time_before(jiffies, max_timeout)); 239 + 240 + /* 241 + * The Goodix panel will send spurious interrupts after a 242 + * 'finger up' event, which will always cause a timeout. 243 + */ 244 + return 0; 230 245 } 231 246 232 247 static void goodix_ts_report_touch(struct goodix_ts_data *ts, u8 *coor_data)
+2 -4
drivers/input/touchscreen/stmfts.c
··· 663 663 sdata->input->open = stmfts_input_open; 664 664 sdata->input->close = stmfts_input_close; 665 665 666 + input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_X); 667 + input_set_capability(sdata->input, EV_ABS, ABS_MT_POSITION_Y); 666 668 touchscreen_parse_properties(sdata->input, true, &sdata->prop); 667 669 668 - input_set_abs_params(sdata->input, ABS_MT_POSITION_X, 0, 669 - sdata->prop.max_x, 0, 0); 670 - input_set_abs_params(sdata->input, ABS_MT_POSITION_Y, 0, 671 - sdata->prop.max_y, 0, 0); 672 670 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MAJOR, 0, 255, 0, 0); 673 671 input_set_abs_params(sdata->input, ABS_MT_TOUCH_MINOR, 0, 255, 0, 0); 674 672 input_set_abs_params(sdata->input, ABS_MT_ORIENTATION, 0, 255, 0, 0);
+1 -1
drivers/input/touchscreen/ti_am335x_tsc.c
··· 161 161 break; 162 162 case 5: 163 163 config |= ts_dev->bit_xp | STEPCONFIG_INP_AN4 | 164 - ts_dev->bit_xn | ts_dev->bit_yp; 164 + STEPCONFIG_XNP | STEPCONFIG_YPN; 165 165 break; 166 166 case 8: 167 167 config |= ts_dev->bit_yp | STEPCONFIG_INP(ts_dev->inp_xp);
+7
include/linux/input.h
··· 234 234 #error "SW_MAX and INPUT_DEVICE_ID_SW_MAX do not match" 235 235 #endif 236 236 237 + #if INPUT_PROP_MAX != INPUT_DEVICE_ID_PROP_MAX 238 + #error "INPUT_PROP_MAX and INPUT_DEVICE_ID_PROP_MAX do not match" 239 + #endif 240 + 237 241 #define INPUT_DEVICE_ID_MATCH_DEVICE \ 238 242 (INPUT_DEVICE_ID_MATCH_BUS | INPUT_DEVICE_ID_MATCH_VENDOR | INPUT_DEVICE_ID_MATCH_PRODUCT) 239 243 #define INPUT_DEVICE_ID_MATCH_DEVICE_AND_VERSION \ ··· 472 468 int input_get_keycode(struct input_dev *dev, struct input_keymap_entry *ke); 473 469 int input_set_keycode(struct input_dev *dev, 474 470 const struct input_keymap_entry *ke); 471 + 472 + bool input_match_device_id(const struct input_dev *dev, 473 + const struct input_device_id *id); 475 474 476 475 void input_enable_softrepeat(struct input_dev *dev, int delay, int period); 477 476
+3
include/linux/mod_devicetable.h
··· 293 293 #define INPUT_DEVICE_ID_SND_MAX 0x07 294 294 #define INPUT_DEVICE_ID_FF_MAX 0x7f 295 295 #define INPUT_DEVICE_ID_SW_MAX 0x0f 296 + #define INPUT_DEVICE_ID_PROP_MAX 0x1f 296 297 297 298 #define INPUT_DEVICE_ID_MATCH_BUS 1 298 299 #define INPUT_DEVICE_ID_MATCH_VENDOR 2 ··· 309 308 #define INPUT_DEVICE_ID_MATCH_SNDBIT 0x0400 310 309 #define INPUT_DEVICE_ID_MATCH_FFBIT 0x0800 311 310 #define INPUT_DEVICE_ID_MATCH_SWBIT 0x1000 311 + #define INPUT_DEVICE_ID_MATCH_PROPBIT 0x2000 312 312 313 313 struct input_device_id { 314 314 ··· 329 327 kernel_ulong_t sndbit[INPUT_DEVICE_ID_SND_MAX / BITS_PER_LONG + 1]; 330 328 kernel_ulong_t ffbit[INPUT_DEVICE_ID_FF_MAX / BITS_PER_LONG + 1]; 331 329 kernel_ulong_t swbit[INPUT_DEVICE_ID_SW_MAX / BITS_PER_LONG + 1]; 330 + kernel_ulong_t propbit[INPUT_DEVICE_ID_PROP_MAX / BITS_PER_LONG + 1]; 332 331 333 332 kernel_ulong_t driver_info; 334 333 };
+1
scripts/mod/devicetable-offsets.c
··· 105 105 DEVID_FIELD(input_device_id, sndbit); 106 106 DEVID_FIELD(input_device_id, ffbit); 107 107 DEVID_FIELD(input_device_id, swbit); 108 + DEVID_FIELD(input_device_id, propbit); 108 109 109 110 DEVID(eisa_device_id); 110 111 DEVID_FIELD(eisa_device_id, sig);
+5 -1
scripts/mod/file2alias.c
··· 761 761 sprintf(alias + strlen(alias), "%X,*", i); 762 762 } 763 763 764 - /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwX where X is comma-separated %02X. */ 764 + /* input:b0v0p0e0-eXkXrXaXmXlXsXfXwXprX where X is comma-separated %02X. */ 765 765 static int do_input_entry(const char *filename, void *symval, 766 766 char *alias) 767 767 { ··· 779 779 DEF_FIELD_ADDR(symval, input_device_id, sndbit); 780 780 DEF_FIELD_ADDR(symval, input_device_id, ffbit); 781 781 DEF_FIELD_ADDR(symval, input_device_id, swbit); 782 + DEF_FIELD_ADDR(symval, input_device_id, propbit); 782 783 783 784 sprintf(alias, "input:"); 784 785 ··· 817 816 sprintf(alias + strlen(alias), "w*"); 818 817 if (flags & INPUT_DEVICE_ID_MATCH_SWBIT) 819 818 do_input(alias, *swbit, 0, INPUT_DEVICE_ID_SW_MAX); 819 + sprintf(alias + strlen(alias), "pr*"); 820 + if (flags & INPUT_DEVICE_ID_MATCH_PROPBIT) 821 + do_input(alias, *propbit, 0, INPUT_DEVICE_ID_PROP_MAX); 820 822 return 1; 821 823 } 822 824 ADD_TO_DEVTABLE("input", input_device_id, do_input_entry);