Merge branch 'for-5.12/core' into for-linus
authorJiri Kosina <jkosina@suse.cz>
Tue, 23 Feb 2021 10:30:01 +0000 (11:30 +0100)
committerJiri Kosina <jkosina@suse.cz>
Tue, 23 Feb 2021 10:30:01 +0000 (11:30 +0100)
- improved handling of generic HID keyboard (no more splitting system
  and consumer controls away), in order to make it easier for userspace
  to figure out the details of the device easier. From Dmitry Torokhov.

- report data sanitization fixes from Will McVicker and Randy Dunlap

20 files changed:
drivers/hid/Kconfig
drivers/hid/amd-sfh-hid/amd_sfh_client.c
drivers/hid/amd-sfh-hid/amd_sfh_hid.h
drivers/hid/amd-sfh-hid/amd_sfh_pcie.c
drivers/hid/amd-sfh-hid/amd_sfh_pcie.h
drivers/hid/hid-ids.h
drivers/hid/hid-input.c
drivers/hid/hid-ite.c
drivers/hid/hid-logitech-dj.c
drivers/hid/hid-logitech-hidpp.c
drivers/hid/hid-multitouch.c
drivers/hid/hid-roccat-arvo.c
drivers/hid/hid-uclogic-params.c
drivers/hid/hid-wiimote-core.c
drivers/hid/i2c-hid/i2c-hid-core.c
drivers/hid/intel-ish-hid/ipc/hw-ish.h
drivers/hid/intel-ish-hid/ipc/pci-ish.c
drivers/hid/wacom_sys.c
drivers/hid/wacom_wac.c
drivers/hid/wacom_wac.h

index 7bdda1b5b2217420cc1fe9860b7477b8bfac5749..09fa75a2b289e5e31c457d85fa4c6db90c3e86ed 100644 (file)
@@ -899,6 +899,7 @@ config HID_SONY
        depends on NEW_LEDS
        depends on LEDS_CLASS
        select POWER_SUPPLY
+       select CRC32
        help
        Support for
 
index 3d1ccac5d99a34a519dc5148e07780807d4a2b98..2ab38b715347717142c9805a902869c25fc10cf6 100644 (file)
@@ -154,7 +154,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
 
        for (i = 0; i < cl_data->num_hid_devices; i++) {
                cl_data->sensor_virt_addr[i] = dma_alloc_coherent(dev, sizeof(int) * 8,
-                                                                 &cl_data->sensor_phys_addr[i],
+                                                                 &cl_data->sensor_dma_addr[i],
                                                                  GFP_KERNEL);
                cl_data->sensor_sts[i] = 0;
                cl_data->sensor_requested_cnt[i] = 0;
@@ -187,7 +187,7 @@ int amd_sfh_hid_client_init(struct amd_mp2_dev *privdata)
                }
                info.period = msecs_to_jiffies(AMD_SFH_IDLE_LOOP);
                info.sensor_idx = cl_idx;
-               info.phys_address = cl_data->sensor_phys_addr[i];
+               info.dma_address = cl_data->sensor_dma_addr[i];
 
                cl_data->report_descr[i] = kzalloc(cl_data->report_descr_sz[i], GFP_KERNEL);
                if (!cl_data->report_descr[i]) {
@@ -212,7 +212,7 @@ cleanup:
                if (cl_data->sensor_virt_addr[i]) {
                        dma_free_coherent(&privdata->pdev->dev, 8 * sizeof(int),
                                          cl_data->sensor_virt_addr[i],
-                                         cl_data->sensor_phys_addr[i]);
+                                         cl_data->sensor_dma_addr[i]);
                }
                kfree(cl_data->feature_report[i]);
                kfree(cl_data->input_report[i]);
@@ -238,7 +238,7 @@ int amd_sfh_hid_client_deinit(struct amd_mp2_dev *privdata)
                if (cl_data->sensor_virt_addr[i]) {
                        dma_free_coherent(&privdata->pdev->dev, 8 * sizeof(int),
                                          cl_data->sensor_virt_addr[i],
-                                         cl_data->sensor_phys_addr[i]);
+                                         cl_data->sensor_dma_addr[i]);
                }
        }
        kfree(cl_data);
index 6be0783d885ce5f91e808760dfc9f152c9bcb220..d7eac1728e314add855c917ba5e07edf4e95c443 100644 (file)
@@ -27,7 +27,7 @@ struct amdtp_cl_data {
        int hid_descr_size[MAX_HID_DEVICES];
        phys_addr_t phys_addr_base;
        u32 *sensor_virt_addr[MAX_HID_DEVICES];
-       phys_addr_t sensor_phys_addr[MAX_HID_DEVICES];
+       dma_addr_t sensor_dma_addr[MAX_HID_DEVICES];
        u32 sensor_sts[MAX_HID_DEVICES];
        u32 sensor_requested_cnt[MAX_HID_DEVICES];
        u8 report_type[MAX_HID_DEVICES];
index a51c7b76283bb46b156fe405cf487a986d1cdd3e..dbac1664166277ba2117b2dde68677699200cfd6 100644 (file)
@@ -41,7 +41,7 @@ void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info i
        cmd_param.s.buf_layout = 1;
        cmd_param.s.buf_length = 16;
 
-       writeq(info.phys_address, privdata->mmio + AMD_C2P_MSG2);
+       writeq(info.dma_address, privdata->mmio + AMD_C2P_MSG2);
        writel(cmd_param.ul, privdata->mmio + AMD_C2P_MSG1);
        writel(cmd_base.ul, privdata->mmio + AMD_C2P_MSG0);
 }
index e8be94f935b78f862bd7cb0da3e07613b7e6ae49..8f8d19b2cfe5ba611ac62ea0fdf63327abe74a97 100644 (file)
@@ -67,7 +67,7 @@ struct amd_mp2_dev {
 struct amd_mp2_sensor_info {
        u8 sensor_idx;
        u32 period;
-       phys_addr_t phys_address;
+       dma_addr_t dma_address;
 };
 
 void amd_start_sensor(struct amd_mp2_dev *privdata, struct amd_mp2_sensor_info info);
index 4c5f23640f9c7434260346a41d3036d32ddd9da7..5db0735c8438a9a220dd3f324ea85106eafe60f0 100644 (file)
 #define USB_DEVICE_ID_TOSHIBA_CLICK_L9W        0x0401
 #define USB_DEVICE_ID_HP_X2            0x074d
 #define USB_DEVICE_ID_HP_X2_10_COVER   0x0755
+#define I2C_DEVICE_ID_HP_SPECTRE_X360_15       0x2817
+#define USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN   0x2706
 
 #define USB_VENDOR_ID_ELECOM           0x056e
 #define USB_DEVICE_ID_ELECOM_BM084     0x0061
 #define USB_DEVICE_ID_INNEX_GENESIS_ATARI      0x4745
 
 #define USB_VENDOR_ID_ITE               0x048d
+#define I2C_VENDOR_ID_ITE              0x103c
+#define I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15      0x184f
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA   0x8386
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA2  0x8350
 #define I2C_DEVICE_ID_ITE_LENOVO_LEGION_Y720   0x837a
index 2040515d49f8a393fa00823ac910c4d0d43e8a2b..236bccd37760dbc642d7a6cda2aeceef8712e632 100644 (file)
@@ -322,6 +322,10 @@ static const struct hid_device_id hid_battery_quirks[] = {
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH,
                USB_DEVICE_ID_LOGITECH_DINOVO_EDGE_KBD),
          HID_BATTERY_QUIRK_IGNORE },
+       { HID_USB_DEVICE(USB_VENDOR_ID_ELAN, USB_DEVICE_ID_ASUS_UX550_TOUCHSCREEN),
+         HID_BATTERY_QUIRK_IGNORE },
+       { HID_I2C_DEVICE(USB_VENDOR_ID_ELAN, I2C_DEVICE_ID_HP_SPECTRE_X360_15),
+         HID_BATTERY_QUIRK_IGNORE },
        {}
 };
 
index 22bfbebceaf44b2685af83d354d3fa79ec6dc05f..14fc068affada8aadaa6584c85a52c831eeac4b7 100644 (file)
@@ -23,11 +23,16 @@ static __u8 *ite_report_fixup(struct hid_device *hdev, __u8 *rdesc, unsigned int
                        hid_info(hdev, "Fixing up Acer Sw5-012 ITE keyboard report descriptor\n");
                        rdesc[163] = HID_MAIN_ITEM_RELATIVE;
                }
-               /* For Acer One S1002 keyboard-dock */
+               /* For Acer One S1002/S1003 keyboard-dock */
                if (*rsize == 188 && rdesc[185] == 0x81 && rdesc[186] == 0x02) {
-                       hid_info(hdev, "Fixing up Acer S1002 ITE keyboard report descriptor\n");
+                       hid_info(hdev, "Fixing up Acer S1002/S1003 ITE keyboard report descriptor\n");
                        rdesc[186] = HID_MAIN_ITEM_RELATIVE;
                }
+               /* For Acer Aspire Switch 10E (SW3-016) keyboard-dock */
+               if (*rsize == 210 && rdesc[184] == 0x81 && rdesc[185] == 0x02) {
+                       hid_info(hdev, "Fixing up Acer Aspire Switch 10E (SW3-016) ITE keyboard report descriptor\n");
+                       rdesc[185] = HID_MAIN_ITEM_RELATIVE;
+               }
        }
 
        return rdesc;
@@ -114,7 +119,8 @@ static const struct hid_device_id ite_devices[] = {
        /* ITE8910 USB kbd ctlr, with Synaptics touchpad connected to it. */
        { HID_DEVICE(BUS_USB, HID_GROUP_GENERIC,
                     USB_VENDOR_ID_SYNAPTICS,
-                    USB_DEVICE_ID_SYNAPTICS_ACER_ONE_S1003) },
+                    USB_DEVICE_ID_SYNAPTICS_ACER_ONE_S1003),
+         .driver_data = QUIRK_TOUCHPAD_ON_OFF_REPORT },
        { }
 };
 MODULE_DEVICE_TABLE(hid, ite_devices);
index 1ffcfc9a1e033b9015a2c88ce72b2b5710e4ee49..271bd8d2433958c8470bdb4e0308e05eb21da32c 100644 (file)
@@ -980,6 +980,7 @@ static void logi_hidpp_recv_queue_notif(struct hid_device *hdev,
        case 0x07:
                device_type = "eQUAD step 4 Gaming";
                logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
+               workitem.reports_supported |= STD_KEYBOARD;
                break;
        case 0x08:
                device_type = "eQUAD step 4 for gamepads";
@@ -994,7 +995,12 @@ static void logi_hidpp_recv_queue_notif(struct hid_device *hdev,
                workitem.reports_supported |= STD_KEYBOARD;
                break;
        case 0x0d:
-               device_type = "eQUAD Lightspeed 1_1";
+               device_type = "eQUAD Lightspeed 1.1";
+               logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
+               workitem.reports_supported |= STD_KEYBOARD;
+               break;
+       case 0x0f:
+               device_type = "eQUAD Lightspeed 1.2";
                logi_hidpp_dev_conn_notif_equad(hdev, hidpp_report, &workitem);
                workitem.reports_supported |= STD_KEYBOARD;
                break;
@@ -1869,6 +1875,10 @@ static const struct hid_device_id logi_dj_receivers[] = {
          HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
                0xc531),
         .driver_data = recvr_type_gaming_hidpp},
+       { /* Logitech G602 receiver (0xc537) */
+         HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
+               0xc537),
+        .driver_data = recvr_type_gaming_hidpp},
        { /* Logitech lightspeed receiver (0xc539) */
          HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH,
                USB_DEVICE_ID_LOGITECH_NANO_RECEIVER_LIGHTSPEED_1),
index f85781464807d130b41797b2b57274438a7e4ca9..7eb9a6ddb46a67e7d06866b923f0bf0994c7b1b9 100644 (file)
@@ -4053,6 +4053,8 @@ static const struct hid_device_id hidpp_devices[] = {
        { /* MX Master mouse over Bluetooth */
          HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb012),
          .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
+       { /* MX Ergo trackball over Bluetooth */
+         HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01d) },
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_LOGITECH, 0xb01e),
          .driver_data = HIDPP_QUIRK_HI_RES_SCROLL_X2121 },
        { /* MX Master 3 mouse over Bluetooth */
index d670bcd57bdef88870661a81fd9179d72a3077cd..8429ebe7097e4c8f9235c35a22e5ab2ace6eb6f6 100644 (file)
@@ -758,7 +758,8 @@ static int mt_touch_input_mapping(struct hid_device *hdev, struct hid_input *hi,
                        MT_STORE_FIELD(inrange_state);
                        return 1;
                case HID_DG_CONFIDENCE:
-                       if (cls->name == MT_CLS_WIN_8 &&
+                       if ((cls->name == MT_CLS_WIN_8 ||
+                            cls->name == MT_CLS_WIN_8_FORCE_MULTI_INPUT) &&
                                (field->application == HID_DG_TOUCHPAD ||
                                 field->application == HID_DG_TOUCHSCREEN))
                                app->quirks |= MT_QUIRK_CONFIDENCE;
@@ -2054,6 +2055,10 @@ static const struct hid_device_id mt_devices[] = {
                HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
                        USB_VENDOR_ID_SYNAPTICS, 0xce08) },
 
+       { .driver_data = MT_CLS_WIN_8_FORCE_MULTI_INPUT,
+               HID_DEVICE(BUS_I2C, HID_GROUP_MULTITOUCH_WIN_8,
+                       USB_VENDOR_ID_SYNAPTICS, 0xce09) },
+
        /* TopSeed panels */
        { .driver_data = MT_CLS_TOPSEED,
                MT_USB_DEVICE(USB_VENDOR_ID_TOPSEED2,
index ffcd444ae2ba6e01d2a6aebebb7dd876b47ae6a9..4556d2a50f754ebd56feea419e3aafb950627eea 100644 (file)
@@ -42,7 +42,7 @@ static ssize_t arvo_sysfs_show_mode_key(struct device *dev,
        if (retval)
                return retval;
 
-       return snprintf(buf, PAGE_SIZE, "%d\n", temp_buf.state);
+       return sysfs_emit(buf, "%d\n", temp_buf.state);
 }
 
 static ssize_t arvo_sysfs_set_mode_key(struct device *dev,
@@ -92,7 +92,7 @@ static ssize_t arvo_sysfs_show_key_mask(struct device *dev,
        if (retval)
                return retval;
 
-       return snprintf(buf, PAGE_SIZE, "%d\n", temp_buf.key_mask);
+       return sysfs_emit(buf, "%d\n", temp_buf.key_mask);
 }
 
 static ssize_t arvo_sysfs_set_key_mask(struct device *dev,
@@ -146,7 +146,7 @@ static ssize_t arvo_sysfs_show_actual_profile(struct device *dev,
        struct arvo_device *arvo =
                        hid_get_drvdata(dev_get_drvdata(dev->parent->parent));
 
-       return snprintf(buf, PAGE_SIZE, "%d\n", arvo->actual_profile);
+       return sysfs_emit(buf, "%d\n", arvo->actual_profile);
 }
 
 static ssize_t arvo_sysfs_set_actual_profile(struct device *dev,
index d26d8cd98efcfddc869155a07779828c54eee6bc..56406cee401fffcfc4b63f8cd6dc926b7b93dfbb 100644 (file)
@@ -90,7 +90,7 @@ static int uclogic_params_get_str_desc(__u8 **pbuf, struct hid_device *hdev,
                goto cleanup;
        } else if (rc < 0) {
                hid_err(hdev,
-                       "failed retrieving string descriptor #%hhu: %d\n",
+                       "failed retrieving string descriptor #%u: %d\n",
                        idx, rc);
                goto cleanup;
        }
index 41012681cafd1ec469d9bfb19930cf1d4a5c6d00..4399d6c6afef2c2bdb22eb013e4b2ac1a729284e 100644 (file)
@@ -1482,7 +1482,7 @@ static void handler_return(struct wiimote_data *wdata, const __u8 *payload)
                wdata->state.cmd_err = err;
                wiimote_cmd_complete(wdata);
        } else if (err) {
-               hid_warn(wdata->hdev, "Remote error %hhu on req %hhu\n", err,
+               hid_warn(wdata->hdev, "Remote error %u on req %u\n", err,
                                                                        cmd);
        }
 }
index bfe716d7ea441e93763688a27ededa576ec21da3..c586acf2fc0b4bdebe9d8483e9e44b70e3912ba5 100644 (file)
@@ -171,6 +171,8 @@ static const struct i2c_hid_quirks {
                I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV },
        { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
                I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
+       { I2C_VENDOR_ID_ITE, I2C_DEVICE_ID_ITE_VOYO_WINPAD_A15,
+               I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
        { I2C_VENDOR_ID_RAYDIUM, I2C_PRODUCT_ID_RAYDIUM_3118,
                I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
        { USB_VENDOR_ID_ELAN, HID_ANY_ID,
index 1fb294ca463e5b566b577b26eefe5e38c40496d0..21b0e6123754eb26ce68030e4fb9007829d99ac6 100644 (file)
@@ -27,6 +27,7 @@
 #define CMP_H_DEVICE_ID                0x06FC
 #define EHL_Ax_DEVICE_ID       0x4BB3
 #define TGL_LP_DEVICE_ID       0xA0FC
+#define TGL_H_DEVICE_ID                0x43FC
 
 #define        REVISION_ID_CHT_A0      0x6
 #define        REVISION_ID_CHT_Ax_SI   0x0
index c6d48a8648b707e27775c54aeb4fec54fc955315..6dea657b7b152e807f1a90436108c075348b30cc 100644 (file)
@@ -37,6 +37,7 @@ static const struct pci_device_id ish_pci_tbl[] = {
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, CMP_H_DEVICE_ID)},
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, EHL_Ax_DEVICE_ID)},
        {PCI_DEVICE(PCI_VENDOR_ID_INTEL, TGL_LP_DEVICE_ID)},
+       {PCI_DEVICE(PCI_VENDOR_ID_INTEL, TGL_H_DEVICE_ID)},
        {0, }
 };
 MODULE_DEVICE_TABLE(pci, ish_pci_tbl);
index 045c464228d91f6a9bb8cba52fc5360ec7331013..8328ef155c4682506bb7a2d7dbdbaffff406632a 100644 (file)
@@ -147,9 +147,9 @@ static int wacom_wac_pen_serial_enforce(struct hid_device *hdev,
        }
 
        if (flush)
-               wacom_wac_queue_flush(hdev, &wacom_wac->pen_fifo);
+               wacom_wac_queue_flush(hdev, wacom_wac->pen_fifo);
        else if (insert)
-               wacom_wac_queue_insert(hdev, &wacom_wac->pen_fifo,
+               wacom_wac_queue_insert(hdev, wacom_wac->pen_fifo,
                                       raw_data, report_size);
 
        return insert && !flush;
@@ -1270,6 +1270,38 @@ static int wacom_devm_sysfs_create_group(struct wacom *wacom,
                                               group);
 }
 
+static void wacom_devm_kfifo_release(struct device *dev, void *res)
+{
+       struct kfifo_rec_ptr_2 *devres = res;
+
+       kfifo_free(devres);
+}
+
+static int wacom_devm_kfifo_alloc(struct wacom *wacom)
+{
+       struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+       struct kfifo_rec_ptr_2 *pen_fifo;
+       int error;
+
+       pen_fifo = devres_alloc(wacom_devm_kfifo_release,
+                             sizeof(struct kfifo_rec_ptr_2),
+                             GFP_KERNEL);
+
+       if (!pen_fifo)
+               return -ENOMEM;
+
+       error = kfifo_alloc(pen_fifo, WACOM_PKGLEN_MAX, GFP_KERNEL);
+       if (error) {
+               devres_free(pen_fifo);
+               return error;
+       }
+
+       devres_add(&wacom->hdev->dev, pen_fifo);
+       wacom_wac->pen_fifo = pen_fifo;
+
+       return 0;
+}
+
 enum led_brightness wacom_leds_brightness_get(struct wacom_led *led)
 {
        struct wacom *wacom = led->wacom;
@@ -1793,7 +1825,7 @@ static ssize_t wacom_show_speed(struct device *dev,
        struct hid_device *hdev = to_hid_device(dev);
        struct wacom *wacom = hid_get_drvdata(hdev);
 
-       return snprintf(buf, PAGE_SIZE, "%i\n", wacom->wacom_wac.bt_high_speed);
+       return sysfs_emit(buf, "%i\n", wacom->wacom_wac.bt_high_speed);
 }
 
 static ssize_t wacom_store_speed(struct device *dev,
@@ -2724,7 +2756,7 @@ static int wacom_probe(struct hid_device *hdev,
        if (features->check_for_hid_type && features->hid_type != hdev->type)
                return -ENODEV;
 
-       error = kfifo_alloc(&wacom_wac->pen_fifo, WACOM_PKGLEN_MAX, GFP_KERNEL);
+       error = wacom_devm_kfifo_alloc(wacom);
        if (error)
                return error;
 
@@ -2786,8 +2818,6 @@ static void wacom_remove(struct hid_device *hdev)
 
        if (wacom->wacom_wac.features.type != REMOTE)
                wacom_release_resources(wacom);
-
-       kfifo_free(&wacom_wac->pen_fifo);
 }
 
 #ifdef CONFIG_PM
index 1bd0eb71559cafe2daa7e97cfcae4b6aea687c1e..44d715c12f6ab77f800b68d917cce1c455ac3c15 100644 (file)
@@ -2600,7 +2600,12 @@ static void wacom_wac_finger_event(struct hid_device *hdev,
                wacom_wac->is_invalid_bt_frame = !value;
                return;
        case HID_DG_CONTACTMAX:
-               features->touch_max = value;
+               if (!features->touch_max) {
+                       features->touch_max = value;
+               } else {
+                       hid_warn(hdev, "%s: ignoring attempt to overwrite non-zero touch_max "
+                                "%d -> %d\n", __func__, features->touch_max, value);
+               }
                return;
        }
 
index da612b6e9c7796f32202c37e7b2a0b56b6db4eec..195910dd2154e2e5471df45a17f4454ffa219787 100644 (file)
@@ -342,7 +342,7 @@ struct wacom_wac {
        struct input_dev *pen_input;
        struct input_dev *touch_input;
        struct input_dev *pad_input;
-       struct kfifo_rec_ptr_2 pen_fifo;
+       struct kfifo_rec_ptr_2 *pen_fifo;
        int pid;
        int num_contacts_left;
        u8 bt_features;