Merge branch 'for-5.1/hid-topseed' into for-linus
authorJiri Kosina <jkosina@suse.cz>
Tue, 5 Mar 2019 14:27:46 +0000 (15:27 +0100)
committerJiri Kosina <jkosina@suse.cz>
Tue, 5 Mar 2019 14:27:46 +0000 (15:27 +0100)
Toshiba WT10A tablet bluetooth keyboard support from Hans de Goede

14 files changed:
drivers/hid/Kconfig
drivers/hid/Makefile
drivers/hid/hid-asus.c
drivers/hid/hid-elan.c
drivers/hid/hid-ids.h
drivers/hid/hid-input.c
drivers/hid/hid-lg.c
drivers/hid/hid-lg4ff.c
drivers/hid/hid-maltron.c [new file with mode: 0644]
drivers/hid/hid-multitouch.c
drivers/hid/hid-quirks.c
drivers/hid/hid-roccat-kone.c
drivers/hid/hid-sony.c
drivers/hid/hid-steam.c

index 41e9935..661fe61 100644 (file)
@@ -590,6 +590,13 @@ config HID_MAGICMOUSE
        Say Y here if you want support for the multi-touch features of the
        Apple Wireless "Magic" Mouse and the Apple Wireless "Magic" Trackpad.
 
+config HID_MALTRON
+       tristate "Maltron L90 keyboard"
+       depends on HID
+       ---help---
+       Adds support for the volume up, volume down, mute, and play/pause buttons
+       of the Maltron L90 keyboard.
+
 config HID_MAYFLASH
        tristate "Mayflash game controller adapter force feedback"
        depends on HID
index 896a51c..cf27520 100644 (file)
@@ -66,6 +66,7 @@ obj-$(CONFIG_HID_LOGITECH)    += hid-logitech.o
 obj-$(CONFIG_HID_LOGITECH_DJ)  += hid-logitech-dj.o
 obj-$(CONFIG_HID_LOGITECH_HIDPP)       += hid-logitech-hidpp.o
 obj-$(CONFIG_HID_MAGICMOUSE)   += hid-magicmouse.o
+obj-$(CONFIG_HID_MALTRON)      += hid-maltron.o
 obj-$(CONFIG_HID_MAYFLASH)     += hid-mf.o
 obj-$(CONFIG_HID_MICROSOFT)    += hid-microsoft.o
 obj-$(CONFIG_HID_MONTEREY)     += hid-monterey.o
index 951bb17..336aeae 100644 (file)
@@ -32,6 +32,7 @@
 #include <linux/platform_data/x86/asus-wmi.h>
 #include <linux/input/mt.h>
 #include <linux/usb.h> /* For to_usb_interface for T100 touchpad intf check */
+#include <linux/power_supply.h>
 
 #include "hid-ids.h"
 
@@ -61,6 +62,13 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
 #define CONTACT_TOUCH_MAJOR_MASK 0x07
 #define CONTACT_PRESSURE_MASK 0x7f
 
+#define        BATTERY_REPORT_ID       (0x03)
+#define        BATTERY_REPORT_SIZE     (1 + 8)
+#define        BATTERY_LEVEL_MAX       ((u8)255)
+#define        BATTERY_STAT_DISCONNECT (0)
+#define        BATTERY_STAT_CHARGING   (1)
+#define        BATTERY_STAT_FULL       (2)
+
 #define QUIRK_FIX_NOTEBOOK_REPORT      BIT(0)
 #define QUIRK_NO_INIT_REPORTS          BIT(1)
 #define QUIRK_SKIP_INPUT_MAPPING       BIT(2)
@@ -71,6 +79,7 @@ MODULE_DESCRIPTION("Asus HID Keyboard and TouchPad");
 #define QUIRK_T100CHI                  BIT(7)
 #define QUIRK_G752_KEYBOARD            BIT(8)
 #define QUIRK_T101HA_DOCK              BIT(9)
+#define QUIRK_T90CHI                   BIT(10)
 
 #define I2C_KEYBOARD_QUIRKS                    (QUIRK_FIX_NOTEBOOK_REPORT | \
                                                 QUIRK_NO_INIT_REPORTS | \
@@ -100,12 +109,21 @@ struct asus_touchpad_info {
 
 struct asus_drvdata {
        unsigned long quirks;
+       struct hid_device *hdev;
        struct input_dev *input;
        struct asus_kbd_leds *kbd_backlight;
        const struct asus_touchpad_info *tp;
        bool enable_backlight;
+       struct power_supply *battery;
+       struct power_supply_desc battery_desc;
+       int battery_capacity;
+       int battery_stat;
+       bool battery_in_query;
+       unsigned long battery_next_query;
 };
 
+static int asus_report_battery(struct asus_drvdata *, u8 *, int);
+
 static const struct asus_touchpad_info asus_i2c_tp = {
        .max_x = 2794,
        .max_y = 1758,
@@ -259,6 +277,9 @@ static int asus_raw_event(struct hid_device *hdev,
 {
        struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
 
+       if (drvdata->battery && data[0] == BATTERY_REPORT_ID)
+               return asus_report_battery(drvdata, data, size);
+
        if (drvdata->tp && data[0] == INPUT_REPORT_ID)
                return asus_report_input(drvdata, data, size);
 
@@ -428,6 +449,164 @@ static int asus_kbd_register_leds(struct hid_device *hdev)
        return ret;
 }
 
+/*
+ * [0]       REPORT_ID (same value defined in report descriptor)
+ * [1]      rest battery level. range [0..255]
+ * [2]..[7]  Bluetooth hardware address (MAC address)
+ * [8]       charging status
+ *            = 0 : AC offline / discharging
+ *            = 1 : AC online  / charging
+ *            = 2 : AC online  / fully charged
+ */
+static int asus_parse_battery(struct asus_drvdata *drvdata, u8 *data, int size)
+{
+       u8 sts;
+       u8 lvl;
+       int val;
+
+       lvl = data[1];
+       sts = data[8];
+
+       drvdata->battery_capacity = ((int)lvl * 100) / (int)BATTERY_LEVEL_MAX;
+
+       switch (sts) {
+       case BATTERY_STAT_CHARGING:
+               val = POWER_SUPPLY_STATUS_CHARGING;
+               break;
+       case BATTERY_STAT_FULL:
+               val = POWER_SUPPLY_STATUS_FULL;
+               break;
+       case BATTERY_STAT_DISCONNECT:
+       default:
+               val = POWER_SUPPLY_STATUS_DISCHARGING;
+               break;
+       }
+       drvdata->battery_stat = val;
+
+       return 0;
+}
+
+static int asus_report_battery(struct asus_drvdata *drvdata, u8 *data, int size)
+{
+       /* notify only the autonomous event by device */
+       if ((drvdata->battery_in_query == false) &&
+                        (size == BATTERY_REPORT_SIZE))
+               power_supply_changed(drvdata->battery);
+
+       return 0;
+}
+
+static int asus_battery_query(struct asus_drvdata *drvdata)
+{
+       u8 *buf;
+       int ret = 0;
+
+       buf = kmalloc(BATTERY_REPORT_SIZE, GFP_KERNEL);
+       if (!buf)
+               return -ENOMEM;
+
+       drvdata->battery_in_query = true;
+       ret = hid_hw_raw_request(drvdata->hdev, BATTERY_REPORT_ID,
+                               buf, BATTERY_REPORT_SIZE,
+                               HID_INPUT_REPORT, HID_REQ_GET_REPORT);
+       drvdata->battery_in_query = false;
+       if (ret == BATTERY_REPORT_SIZE)
+               ret = asus_parse_battery(drvdata, buf, BATTERY_REPORT_SIZE);
+       else
+               ret = -ENODATA;
+
+       kfree(buf);
+
+       return ret;
+}
+
+static enum power_supply_property asus_battery_props[] = {
+       POWER_SUPPLY_PROP_STATUS,
+       POWER_SUPPLY_PROP_PRESENT,
+       POWER_SUPPLY_PROP_CAPACITY,
+       POWER_SUPPLY_PROP_SCOPE,
+       POWER_SUPPLY_PROP_MODEL_NAME,
+};
+
+#define        QUERY_MIN_INTERVAL      (60 * HZ)       /* 60[sec] */
+
+static int asus_battery_get_property(struct power_supply *psy,
+                               enum power_supply_property psp,
+                               union power_supply_propval *val)
+{
+       struct asus_drvdata *drvdata = power_supply_get_drvdata(psy);
+       int ret = 0;
+
+       switch (psp) {
+       case POWER_SUPPLY_PROP_STATUS:
+       case POWER_SUPPLY_PROP_CAPACITY:
+               if (time_before(drvdata->battery_next_query, jiffies)) {
+                       drvdata->battery_next_query =
+                                        jiffies + QUERY_MIN_INTERVAL;
+                       ret = asus_battery_query(drvdata);
+                       if (ret)
+                               return ret;
+               }
+               if (psp == POWER_SUPPLY_PROP_STATUS)
+                       val->intval = drvdata->battery_stat;
+               else
+                       val->intval = drvdata->battery_capacity;
+               break;
+       case POWER_SUPPLY_PROP_PRESENT:
+               val->intval = 1;
+               break;
+       case POWER_SUPPLY_PROP_SCOPE:
+               val->intval = POWER_SUPPLY_SCOPE_DEVICE;
+               break;
+       case POWER_SUPPLY_PROP_MODEL_NAME:
+               val->strval = drvdata->hdev->name;
+               break;
+       default:
+               ret = -EINVAL;
+               break;
+       }
+
+       return ret;
+}
+
+static int asus_battery_probe(struct hid_device *hdev)
+{
+       struct asus_drvdata *drvdata = hid_get_drvdata(hdev);
+       struct power_supply_config pscfg = { .drv_data = drvdata };
+       int ret = 0;
+
+       drvdata->battery_capacity = 0;
+       drvdata->battery_stat = POWER_SUPPLY_STATUS_UNKNOWN;
+       drvdata->battery_in_query = false;
+
+       drvdata->battery_desc.properties = asus_battery_props;
+       drvdata->battery_desc.num_properties = ARRAY_SIZE(asus_battery_props);
+       drvdata->battery_desc.get_property = asus_battery_get_property;
+       drvdata->battery_desc.type = POWER_SUPPLY_TYPE_BATTERY;
+       drvdata->battery_desc.use_for_apm = 0;
+       drvdata->battery_desc.name = devm_kasprintf(&hdev->dev, GFP_KERNEL,
+                                       "asus-keyboard-%s-battery",
+                                       strlen(hdev->uniq) ?
+                                       hdev->uniq : dev_name(&hdev->dev));
+       if (!drvdata->battery_desc.name)
+               return -ENOMEM;
+
+       drvdata->battery_next_query = jiffies;
+
+       drvdata->battery = devm_power_supply_register(&hdev->dev,
+                               &(drvdata->battery_desc), &pscfg);
+       if (IS_ERR(drvdata->battery)) {
+               ret = PTR_ERR(drvdata->battery);
+               drvdata->battery = NULL;
+               hid_err(hdev, "Unable to register battery device\n");
+               return ret;
+       }
+
+       power_supply_powers(drvdata->battery, &hdev->dev);
+
+       return ret;
+}
+
 static int asus_input_configured(struct hid_device *hdev, struct hid_input *hi)
 {
        struct input_dev *input = hi->input;
@@ -500,7 +679,7 @@ static int asus_input_mapping(struct hid_device *hdev,
         * This avoids a bunch of non-functional hid_input devices getting
         * created because of the T100CHI using HID_QUIRK_MULTI_INPUT.
         */
-       if (drvdata->quirks & QUIRK_T100CHI) {
+       if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) {
                if (field->application == (HID_UP_GENDESK | 0x0080) ||
                    usage->hid == (HID_UP_GENDEVCTRLS | 0x0024) ||
                    usage->hid == (HID_UP_GENDEVCTRLS | 0x0025) ||
@@ -660,6 +839,15 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
        drvdata->quirks = id->driver_data;
 
+       /*
+        * T90CHI's keyboard dock returns same ID values as T100CHI's dock.
+        * Thus, identify T90CHI dock with product name string.
+        */
+       if (strstr(hdev->name, "T90CHI")) {
+               drvdata->quirks &= ~QUIRK_T100CHI;
+               drvdata->quirks |= QUIRK_T90CHI;
+       }
+
        if (drvdata->quirks & QUIRK_IS_MULTITOUCH)
                drvdata->tp = &asus_i2c_tp;
 
@@ -694,6 +882,17 @@ static int asus_probe(struct hid_device *hdev, const struct hid_device_id *id)
        if (drvdata->quirks & QUIRK_NO_INIT_REPORTS)
                hdev->quirks |= HID_QUIRK_NO_INIT_REPORTS;
 
+       drvdata->hdev = hdev;
+
+       if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) {
+               ret = asus_battery_probe(hdev);
+               if (ret) {
+                       hid_err(hdev,
+                           "Asus hid battery_probe failed: %d\n", ret);
+                       return ret;
+               }
+       }
+
        ret = hid_parse(hdev);
        if (ret) {
                hid_err(hdev, "Asus hid parse failed: %d\n", ret);
@@ -769,28 +968,44 @@ static __u8 *asus_report_fixup(struct hid_device *hdev, __u8 *rdesc,
                hid_info(hdev, "Fixing up Asus T100 keyb report descriptor\n");
                rdesc[74] &= ~HID_MAIN_ITEM_CONSTANT;
        }
-       /* For the T100CHI keyboard dock */
-       if (drvdata->quirks & QUIRK_T100CHI &&
-                *rsize == 403 && rdesc[388] == 0x09 && rdesc[389] == 0x76) {
+       /* For the T100CHI/T90CHI keyboard dock */
+       if (drvdata->quirks & (QUIRK_T100CHI | QUIRK_T90CHI)) {
+               int rsize_orig;
+               int offs;
+
+               if (drvdata->quirks & QUIRK_T100CHI) {
+                       rsize_orig = 403;
+                       offs = 388;
+               } else {
+                       rsize_orig = 306;
+                       offs = 291;
+               }
+
                /*
                 * Change Usage (76h) to Usage Minimum (00h), Usage Maximum
                 * (FFh) and clear the flags in the Input() byte.
                 * Note the descriptor has a bogus 0 byte at the end so we
                 * only need 1 extra byte.
                 */
-               *rsize = 404;
-               rdesc = kmemdup(rdesc, *rsize, GFP_KERNEL);
-               if (!rdesc)
-                       return NULL;
-
-               hid_info(hdev, "Fixing up T100CHI keyb report descriptor\n");
-               memmove(rdesc + 392, rdesc + 390, 12);
-               rdesc[388] = 0x19;
-               rdesc[389] = 0x00;
-               rdesc[390] = 0x29;
-               rdesc[391] = 0xff;
-               rdesc[402] = 0x00;
+               if (*rsize == rsize_orig &&
+                       rdesc[offs] == 0x09 && rdesc[offs + 1] == 0x76) {
+                       *rsize = rsize_orig + 1;
+                       rdesc = kmemdup(rdesc, *rsize, GFP_KERNEL);
+                       if (!rdesc)
+                               return NULL;
+
+                       hid_info(hdev, "Fixing up %s keyb report descriptor\n",
+                               drvdata->quirks & QUIRK_T100CHI ?
+                               "T100CHI" : "T90CHI");
+                       memmove(rdesc + offs + 4, rdesc + offs + 2, 12);
+                       rdesc[offs] = 0x19;
+                       rdesc[offs + 1] = 0x00;
+                       rdesc[offs + 2] = 0x29;
+                       rdesc[offs + 3] = 0xff;
+                       rdesc[offs + 14] = 0x00;
+               }
        }
+
        if (drvdata->quirks & QUIRK_G752_KEYBOARD &&
                 *rsize == 75 && rdesc[61] == 0x15 && rdesc[62] == 0x00) {
                /* report is missing usage mninum and maximum */
index 0bfd6d1..1c62095 100644 (file)
@@ -393,7 +393,7 @@ static int elan_start_multitouch(struct hid_device *hdev)
         * This byte sequence will enable multitouch mode and disable
         * mouse emulation
         */
-       const unsigned char buf[] = { 0x0D, 0x00, 0x03, 0x21, 0x00 };
+       static const unsigned char buf[] = { 0x0D, 0x00, 0x03, 0x21, 0x00 };
        unsigned char *dmabuf = kmemdup(buf, sizeof(buf), GFP_KERNEL);
 
        if (!dmabuf)
index 644a9f2..f46e07a 100644 (file)
@@ -72,6 +72,7 @@
 
 #define USB_VENDOR_ID_ALCOR            0x058f
 #define USB_DEVICE_ID_ALCOR_USBRS232   0x9720
+#define USB_DEVICE_ID_ALCOR_MALTRON_KB 0x9410
 
 #define USB_VENDOR_ID_ALPS             0x0433
 #define USB_DEVICE_ID_IBM_GAMEPAD      0x1101
 #define USB_DEVICE_ID_LENOVO_TPPRODOCK 0x6067
 #define USB_DEVICE_ID_LENOVO_X1_COVER  0x6085
 #define USB_DEVICE_ID_LENOVO_X1_TAB    0x60a3
+#define USB_DEVICE_ID_LENOVO_X1_TAB3   0x60b5
 
 #define USB_VENDOR_ID_LG               0x1fd2
 #define USB_DEVICE_ID_LG_MULTITOUCH    0x0064
 #define USB_DEVICE_ID_LOGITECH_WINGMAN_F3D     0xc283
 #define USB_DEVICE_ID_LOGITECH_FORCE3D_PRO     0xc286
 #define USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940      0xc287
+#define USB_DEVICE_ID_LOGITECH_WINGMAN_FG      0xc20e
 #define USB_DEVICE_ID_LOGITECH_WINGMAN_FFG     0xc293
 #define USB_DEVICE_ID_LOGITECH_WHEEL   0xc294
 #define USB_DEVICE_ID_LOGITECH_MOMO_WHEEL      0xc295
index 59a5608..b10b192 100644 (file)
@@ -328,6 +328,9 @@ static const struct hid_device_id hid_battery_quirks[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_SYMBOL,
                USB_DEVICE_ID_SYMBOL_SCANNER_3),
          HID_BATTERY_QUIRK_IGNORE },
+       { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ASUSTEK,
+               USB_DEVICE_ID_ASUSTEK_T100CHI_KEYBOARD),
+         HID_BATTERY_QUIRK_IGNORE },
        {}
 };
 
index 596227d..5d419a9 100644 (file)
@@ -50,6 +50,7 @@
 #define MOMO_RDESC_ORIG_SIZE   87
 #define MOMO2_RDESC_ORIG_SIZE  87
 #define FFG_RDESC_ORIG_SIZE    85
+#define FG_RDESC_ORIG_SIZE     82
 
 /* Fixed report descriptors for Logitech Driving Force (and Pro)
  * wheel controllers
@@ -381,6 +382,49 @@ static __u8 ffg_rdesc_fixed[] = {
 0xC0                /*  End Collection                      */
 };
 
+static __u8 fg_rdesc_fixed[] = {
+0x05, 0x01,         /*  Usage Page (Desktop),               */
+0x09, 0x04,         /*  Usage (Joystik),                    */
+0xA1, 0x01,         /*  Collection (Application),           */
+0xA1, 0x02,         /*      Collection (Logical),           */
+0x15, 0x00,         /*          Logical Minimum (0),        */
+0x26, 0xFF, 0x00,   /*          Logical Maximum (255),      */
+0x35, 0x00,         /*          Physical Minimum (0),       */
+0x46, 0xFF, 0x00,   /*          Physical Maximum (255),     */
+0x75, 0x08,         /*          Report Size (8),            */
+0x95, 0x01,         /*          Report Count (1),           */
+0x09, 0x30,         /*          Usage (X),                  */
+0x81, 0x02,         /*          Input (Variable),           */
+0xA4,               /*  Push,                               */
+0x25, 0x01,         /*          Logical Maximum (1),        */
+0x45, 0x01,         /*          Physical Maximum (1),       */
+0x75, 0x01,         /*          Report Size (1),            */
+0x95, 0x02,         /*          Report Count (2),           */
+0x81, 0x01,         /*          Input (Constant),           */
+0x95, 0x06,         /*          Report Count (6),           */
+0x05, 0x09,         /*          Usage Page (Button),        */
+0x19, 0x01,         /*          Usage Minimum (01h),        */
+0x29, 0x06,         /*          Usage Maximum (06h),        */
+0x81, 0x02,         /*          Input (Variable),           */
+0x05, 0x01,         /*          Usage Page (Desktop),       */
+0xB4,               /*  Pop,                                */
+0x81, 0x02,         /*          Input (Constant),           */
+0x09, 0x31,         /*          Usage (Y),                  */
+0x81, 0x02,         /*          Input (Variable),           */
+0x09, 0x32,         /*          Usage (Z),                  */
+0x81, 0x02,         /*          Input (Variable),           */
+0xC0,               /*      End Collection,                 */
+0xA1, 0x02,         /*      Collection (Logical),           */
+0x26, 0xFF, 0x00,   /*          Logical Maximum (255),      */
+0x46, 0xFF, 0x00,   /*          Physical Maximum (255),     */
+0x75, 0x08,         /*          Report Size (8),            */
+0x95, 0x04,         /*          Report Count (4),           */
+0x09, 0x02,         /*          Usage (02h),                */
+0xB1, 0x02,         /*          Feature (Variable),         */
+0xC0,               /*      End Collection,                 */
+0xC0                /*  End Collection,                     */
+};
+
 /*
  * Certain Logitech keyboards send in report #3 keys which are far
  * above the logical maximum described in descriptor. This extends
@@ -408,6 +452,19 @@ static __u8 *lg_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 
        switch (hdev->product) {
 
+       case USB_DEVICE_ID_LOGITECH_WINGMAN_FG:
+               if (*rsize == FG_RDESC_ORIG_SIZE) {
+                       hid_info(hdev,
+                               "fixing up Logitech Wingman Formula GP report descriptor\n");
+                       rdesc = fg_rdesc_fixed;
+                       *rsize = sizeof(fg_rdesc_fixed);
+               } else {
+                       hid_info(hdev,
+                               "rdesc size test failed for formula gp\n");
+               }
+               break;
+
+
        case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG:
                if (*rsize == FFG_RDESC_ORIG_SIZE) {
                        hid_info(hdev,
@@ -664,6 +721,7 @@ static int lg_input_mapped(struct hid_device *hdev, struct hid_input *hi,
                        usage->code == ABS_RZ)) {
                switch (hdev->product) {
                case USB_DEVICE_ID_LOGITECH_G29_WHEEL:
+               case USB_DEVICE_ID_LOGITECH_WINGMAN_FG:
                case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG:
                case USB_DEVICE_ID_LOGITECH_WHEEL:
                case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
@@ -871,6 +929,8 @@ static const struct hid_device_id lg_devices[] = {
                .driver_data = LG_NOGET | LG_FF4 },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WII_WHEEL),
                .driver_data = LG_FF4 },
+       { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FG),
+               .driver_data = LG_NOGET },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG),
                .driver_data = LG_NOGET | LG_FF4 },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2),
index 512d67e..a299c9d 100644 (file)
@@ -103,6 +103,10 @@ static const signed short lg4ff_wheel_effects[] = {
        -1
 };
 
+static const signed short no_wheel_effects[] = {
+       -1
+};
+
 struct lg4ff_wheel {
        const u32 product_id;
        const signed short *ff_effects;
@@ -137,6 +141,7 @@ struct lg4ff_alternate_mode {
 };
 
 static const struct lg4ff_wheel lg4ff_devices[] = {
+       {USB_DEVICE_ID_LOGITECH_WINGMAN_FG,  no_wheel_effects,    40, 180, NULL},
        {USB_DEVICE_ID_LOGITECH_WINGMAN_FFG, lg4ff_wheel_effects, 40, 180, NULL},
        {USB_DEVICE_ID_LOGITECH_WHEEL,       lg4ff_wheel_effects, 40, 270, NULL},
        {USB_DEVICE_ID_LOGITECH_MOMO_WHEEL,  lg4ff_wheel_effects, 40, 270, NULL},
@@ -346,6 +351,7 @@ int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,
                        rd[5] = rd[3];
                        rd[6] = 0x7F;
                        return 1;
+               case USB_DEVICE_ID_LOGITECH_WINGMAN_FG:
                case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG:
                case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
                case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
diff --git a/drivers/hid/hid-maltron.c b/drivers/hid/hid-maltron.c
new file mode 100644 (file)
index 0000000..dcd6db6
--- /dev/null
@@ -0,0 +1,165 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * HID driver for Maltron L90
+ *
+ * Copyright (c) 1999 Andreas Gal
+ * Copyright (c) 2000-2005 Vojtech Pavlik <vojtech@suse.cz>
+ * Copyright (c) 2005 Michael Haboustak <mike-@cinci.rr.com> for Concept2, Inc
+ * Copyright (c) 2008 Jiri Slaby
+ * Copyright (c) 2012 David Dillow <dave@thedillows.org>
+ * Copyright (c) 2006-2013 Jiri Kosina
+ * Copyright (c) 2013 Colin Leitner <colin.leitner@gmail.com>
+ * Copyright (c) 2014-2016 Frank Praznik <frank.praznik@gmail.com>
+ * Copyright (c) 2010 Richard Nauber <Richard.Nauber@gmail.com>
+ * Copyright (c) 2016 Yuxuan Shui <yshuiv7@gmail.com>
+ * Copyright (c) 2018 William Whistler <wtbw@wtbw.co.uk>
+ */
+
+#include <linux/device.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+
+#include "hid-ids.h"
+
+/* The original buggy USB descriptor */
+static u8 maltron_rdesc_o[] = {
+       0x05, 0x01,        /* Usage Page (Generic Desktop Ctrls) */
+       0x09, 0x80,        /* Usage (Sys Control)                */
+       0xA1, 0x01,        /* Collection (Application)           */
+       0x85, 0x02,        /*   Report ID (2)                    */
+       0x75, 0x01,        /*   Report Size (1)                  */
+       0x95, 0x01,        /*   Report Count (1)                 */
+       0x15, 0x00,        /*   Logical Minimum (0)              */
+       0x25, 0x01,        /*   Logical Maximum (1)              */
+       0x09, 0x82,        /*   Usage (Sys Sleep)                */
+       0x81, 0x06,        /*   Input (Data,Var,Rel)             */
+       0x09, 0x82,        /*   Usage (Sys Sleep)                */
+       0x81, 0x06,        /*   Input (Data,Var,Rel)             */
+       0x09, 0x83,        /*   Usage (Sys Wake Up)              */
+       0x81, 0x06,        /*   Input (Data,Var,Rel)             */
+       0x75, 0x05,        /*   Report Size (5)                  */
+       0x81, 0x01,        /*   Input (Const,Array,Abs)          */
+       0xC0,              /* End Collection                     */
+       0x05, 0x0C,        /* Usage Page (Consumer)              */
+       0x09, 0x01,        /* Usage (Consumer Control)           */
+       0xA1, 0x01,        /* Collection (Application)           */
+       0x85, 0x03,        /*   Report ID (3)                    */
+       0x95, 0x01,        /*   Report Count (1)                 */
+       0x75, 0x10,        /*   Report Size (16)                 */
+       0x19, 0x00,        /*   Usage Minimum (Unassigned)       */
+       0x2A, 0xFF, 0x7F,  /*   Usage Maximum (0x7FFF)           */
+       0x81, 0x00,        /*   Input (Data,Array,Abs)           */
+       0xC0,              /* End Collection                     */
+       0x06, 0x7F, 0xFF,  /* Usage Page (Vendor Defined 0xFF7F) */
+       0x09, 0x01,        /* Usage (0x01)                       */
+       0xA1, 0x01,        /* Collection (Application)           */
+       0x85, 0x04,        /*   Report ID (4)                    */
+       0x95, 0x01,        /*   Report Count (1)                 */
+       0x75, 0x10,        /*   Report Size (16)                 */
+       0x19, 0x00,        /*   Usage Minimum (0x00)             */
+       0x2A, 0xFF, 0x7F,  /*   Usage Maximum (0x7FFF)           */
+       0x81, 0x00,        /*   Input (Data,Array,Abs)           */
+       0x75, 0x02,        /*   Report Size (2)                  */
+       0x25, 0x02,        /*   Logical Maximum (2)              */
+       0x09, 0x90,        /*   Usage (0x90)                     */
+       0xB1, 0x02,        /*   Feature (Data,Var,Abs)           */
+       0x75, 0x06,        /*   Report Size (6)                  */
+       0xB1, 0x01,        /*   Feature (Const,Array,Abs)        */
+       0x75, 0x01,        /*   Report Size (1)                  */
+       0x25, 0x01,        /*   Logical Maximum (1)              */
+       0x05, 0x08,        /*   Usage Page (LEDs)                */
+       0x09, 0x2A,        /*   Usage (On-Line)                  */
+       0x91, 0x02,        /*   Output (Data,Var,Abs)            */
+       0x09, 0x4B,        /*   Usage (Generic Indicator)        */
+       0x91, 0x02,        /*   Output (Data,Var,Abs)            */
+       0x75, 0x06,        /*   Report Size (6)                  */
+       0x95, 0x01,        /*   Report Count (1)                 */
+       0x91, 0x01,        /*   Output (Const,Array,Abs)         */
+       0xC0               /* End Collection                     */
+};
+
+/* The patched descriptor, allowing media key events to be accepted as valid */
+static u8 maltron_rdesc[] = {
+       0x05, 0x01,        /* Usage Page (Generic Desktop Ctrls) */
+       0x09, 0x80,        /* Usage (Sys Control)                */
+       0xA1, 0x01,        /* Collection (Application)           */
+       0x85, 0x02,        /*   Report ID (2)                    */
+       0x75, 0x01,        /*   Report Size (1)                  */
+       0x95, 0x01,        /*   Report Count (1)                 */
+       0x15, 0x00,        /*   Logical Minimum (0)              */
+       0x25, 0x01,        /*   Logical Maximum (1)              */
+       0x09, 0x82,        /*   Usage (Sys Sleep)                */
+       0x81, 0x06,        /*   Input (Data,Var,Rel)             */
+       0x09, 0x82,        /*   Usage (Sys Sleep)                */
+       0x81, 0x06,        /*   Input (Data,Var,Rel)             */
+       0x09, 0x83,        /*   Usage (Sys Wake Up)              */
+       0x81, 0x06,        /*   Input (Data,Var,Rel)             */
+       0x75, 0x05,        /*   Report Size (5)                  */
+       0x81, 0x01,        /*   Input (Const,Array,Abs)          */
+       0xC0,              /* End Collection                     */
+       0x05, 0x0C,        /* Usage Page (Consumer)              */
+       0x09, 0x01,        /* Usage (Consumer Control)           */
+       0xA1, 0x01,        /* Collection (Application)           */
+       0x85, 0x03,        /*   Report ID (3)                    */
+       0x15, 0x00,        /*   Logical Minimum (0)              - changed */
+       0x26, 0xFF, 0x7F,  /*   Logical Maximum (32767)          - changed */
+       0x95, 0x01,        /*   Report Count (1)                 */
+       0x75, 0x10,        /*   Report Size (16)                 */
+       0x19, 0x00,        /*   Usage Minimum (Unassigned)       */
+       0x2A, 0xFF, 0x7F,  /*   Usage Maximum (0x7FFF)           */
+       0x81, 0x00,        /*   Input (Data,Array,Abs)           */
+       0xC0,              /* End Collection                     */
+       0x06, 0x7F, 0xFF,  /* Usage Page (Vendor Defined 0xFF7F) */
+       0x09, 0x01,        /* Usage (0x01)                       */
+       0xA1, 0x01,        /* Collection (Application)           */
+       0x85, 0x04,        /*   Report ID (4)                    */
+       0x95, 0x01,        /*   Report Count (1)                 */
+       0x75, 0x10,        /*   Report Size (16)                 */
+       0x19, 0x00,        /*   Usage Minimum (0x00)             */
+       0x2A, 0xFF, 0x7F,  /*   Usage Maximum (0x7FFF)           */
+       0x81, 0x00,        /*   Input (Data,Array,Abs)           */
+       0x75, 0x02,        /*   Report Size (2)                  */
+       0x25, 0x02,        /*   Logical Maximum (2)              */
+       0x09, 0x90,        /*   Usage (0x90)                     */
+       0xB1, 0x02,        /*   Feature (Data,Var,Abs)           */
+       0x75, 0x06,        /*   Report Size (6)                  */
+       0xB1, 0x01,        /*   Feature (Const,Array,Abs)        */
+       0x75, 0x01,        /*   Report Size (1)                  */
+       0x25, 0x01,        /*   Logical Maximum (1)              */
+       0x05, 0x08,        /*   Usage Page (LEDs)                */
+       0x09, 0x2A,        /*   Usage (On-Line)                  */
+       0x91, 0x02,        /*   Output (Data,Var,Abs)            */
+       0x09, 0x4B,        /*   Usage (Generic Indicator)        */
+       0x91, 0x02,        /*   Output (Data,Var,Abs)            */
+       0x75, 0x06,        /*   Report Size (6)                  */
+       0x95, 0x01,        /*   Report Count (1)                 */
+       0x91, 0x01,        /*   Output (Const,Array,Abs)         */
+       0xC0               /* End Collection                     */
+};
+
+static __u8 *maltron_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+                                 unsigned int *rsize)
+{
+       if (*rsize == sizeof(maltron_rdesc_o) &&
+           !memcmp(maltron_rdesc_o, rdesc, sizeof(maltron_rdesc_o))) {
+               hid_info(hdev, "Replacing Maltron L90 keyboard report descriptor\n");
+               *rsize = sizeof(maltron_rdesc);
+               return maltron_rdesc;
+       }
+       return rdesc;
+}
+
+static const struct hid_device_id maltron_devices[] = {
+       { HID_USB_DEVICE(USB_VENDOR_ID_ALCOR, USB_DEVICE_ID_ALCOR_MALTRON_KB)},
+       { }
+};
+MODULE_DEVICE_TABLE(hid, maltron_devices);
+
+static struct hid_driver maltron_driver = {
+       .name = "maltron",
+       .id_table = maltron_devices,
+       .report_fixup = maltron_report_fixup
+};
+module_hid_driver(maltron_driver);
+
+MODULE_LICENSE("GPL");
index dca0a3a..c02d4ca 100644 (file)
@@ -1780,6 +1780,12 @@ static const struct hid_device_id mt_devices[] = {
                           USB_VENDOR_ID_LENOVO,
                           USB_DEVICE_ID_LENOVO_X1_TAB) },
 
+       /* Lenovo X1 TAB Gen 3 */
+       { .driver_data = MT_CLS_WIN_8_DUAL,
+               HID_DEVICE(BUS_USB, HID_GROUP_MULTITOUCH_WIN_8,
+                          USB_VENDOR_ID_LENOVO,
+                          USB_DEVICE_ID_LENOVO_X1_TAB3) },
+
        /* Anton devices */
        { .driver_data = MT_CLS_EXPORT_ALL_INPUTS,
                MT_USB_DEVICE(USB_VENDOR_ID_ANTON,
index 94088c0..4c063d8 100644 (file)
@@ -451,6 +451,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_RUMBLEPAD2_2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_G29_WHEEL) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_F3D) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FG) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_WINGMAN_FFG) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FORCE3D_PRO) },
        { HID_USB_DEVICE(USB_VENDOR_ID_LOGITECH, USB_DEVICE_ID_LOGITECH_FLIGHT_SYSTEM_G940) },
index bf4675a..c4dd616 100644 (file)
@@ -783,6 +783,7 @@ static void kone_keep_values_up_to_date(struct kone_device *kone,
        case kone_mouse_event_switch_profile:
                kone->actual_dpi = kone->profiles[event->value - 1].
                                startup_dpi;
+               /* fall through */
        case kone_mouse_event_osd_profile:
                kone->actual_profile = event->value;
                break;
index 9671a4b..26fae90 100644 (file)
@@ -58,6 +58,7 @@
 #define FUTUREMAX_DANCE_MAT       BIT(13)
 #define NSG_MR5U_REMOTE_BT        BIT(14)
 #define NSG_MR7U_REMOTE_BT        BIT(15)
+#define SHANWAN_GAMEPAD           BIT(16)
 
 #define SIXAXIS_CONTROLLER (SIXAXIS_CONTROLLER_USB | SIXAXIS_CONTROLLER_BT)
 #define MOTION_CONTROLLER (MOTION_CONTROLLER_USB | MOTION_CONTROLLER_BT)
@@ -1490,6 +1491,7 @@ static int sony_register_sensors(struct sony_sc *sc)
  */
 static int sixaxis_set_operational_usb(struct hid_device *hdev)
 {
+       struct sony_sc *sc = hid_get_drvdata(hdev);
        const int buf_size =
                max(SIXAXIS_REPORT_0xF2_SIZE, SIXAXIS_REPORT_0xF5_SIZE);
        u8 *buf;
@@ -1519,14 +1521,15 @@ static int sixaxis_set_operational_usb(struct hid_device *hdev)
 
        /*
         * But the USB interrupt would cause SHANWAN controllers to
-        * start rumbling non-stop.
+        * start rumbling non-stop, so skip step 3 for these controllers.
         */
-       if (strcmp(hdev->name, "SHANWAN PS3 GamePad")) {
-               ret = hid_hw_output_report(hdev, buf, 1);
-               if (ret < 0) {
-                       hid_info(hdev, "can't set operational mode: step 3, ignoring\n");
-                       ret = 0;
-               }
+       if (sc->quirks & SHANWAN_GAMEPAD)
+               goto out;
+
+       ret = hid_hw_output_report(hdev, buf, 1);
+       if (ret < 0) {
+               hid_info(hdev, "can't set operational mode: step 3, ignoring\n");
+               ret = 0;
        }
 
 out:
@@ -2097,9 +2100,14 @@ static void sixaxis_send_output_report(struct sony_sc *sc)
                }
        }
 
-       hid_hw_raw_request(sc->hdev, report->report_id, (u8 *)report,
-                       sizeof(struct sixaxis_output_report),
-                       HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
+       /* SHANWAN controllers require output reports via intr channel */
+       if (sc->quirks & SHANWAN_GAMEPAD)
+               hid_hw_output_report(sc->hdev, (u8 *)report,
+                               sizeof(struct sixaxis_output_report));
+       else
+               hid_hw_raw_request(sc->hdev, report->report_id, (u8 *)report,
+                               sizeof(struct sixaxis_output_report),
+                               HID_OUTPUT_REPORT, HID_REQ_SET_REPORT);
 }
 
 static void dualshock4_send_output_report(struct sony_sc *sc)
@@ -2811,6 +2819,9 @@ static int sony_probe(struct hid_device *hdev, const struct hid_device_id *id)
        if (!strcmp(hdev->name, "FutureMax Dance Mat"))
                quirks |= FUTUREMAX_DANCE_MAT;
 
+       if (!strcmp(hdev->name, "SHANWAN PS3 GamePad"))
+               quirks |= SHANWAN_GAMEPAD;
+
        sc = devm_kzalloc(&hdev->dev, sizeof(*sc), GFP_KERNEL);
        if (sc == NULL) {
                hid_err(hdev, "can't alloc sony descriptor\n");
index dc4128b..8141cad 100644 (file)
@@ -283,11 +283,6 @@ static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
 static int steam_input_open(struct input_dev *dev)
 {
        struct steam_device *steam = input_get_drvdata(dev);
-       int ret;
-
-       ret = hid_hw_open(steam->hdev);
-       if (ret)
-               return ret;
 
        mutex_lock(&steam->mutex);
        if (!steam->client_opened && lizard_mode)
@@ -304,8 +299,6 @@ static void steam_input_close(struct input_dev *dev)
        if (!steam->client_opened && lizard_mode)
                steam_set_lizard_mode(steam, true);
        mutex_unlock(&steam->mutex);
-
-       hid_hw_close(steam->hdev);
 }
 
 static enum power_supply_property steam_battery_props[] = {
@@ -623,11 +616,6 @@ static void steam_client_ll_stop(struct hid_device *hdev)
 static int steam_client_ll_open(struct hid_device *hdev)
 {
        struct steam_device *steam = hdev->driver_data;
-       int ret;
-
-       ret = hid_hw_open(steam->hdev);
-       if (ret)
-               return ret;
 
        mutex_lock(&steam->mutex);
        steam->client_opened = true;
@@ -635,7 +623,7 @@ static int steam_client_ll_open(struct hid_device *hdev)
 
        steam_input_unregister(steam);
 
-       return ret;
+       return 0;
 }
 
 static void steam_client_ll_close(struct hid_device *hdev)
@@ -646,7 +634,6 @@ static void steam_client_ll_close(struct hid_device *hdev)
        steam->client_opened = false;
        mutex_unlock(&steam->mutex);
 
-       hid_hw_close(steam->hdev);
        if (steam->connected) {
                steam_set_lizard_mode(steam, lizard_mode);
                steam_input_register(steam);
@@ -759,14 +746,15 @@ static int steam_probe(struct hid_device *hdev,
        if (ret)
                goto client_hdev_add_fail;
 
+       ret = hid_hw_open(hdev);
+       if (ret) {
+               hid_err(hdev,
+                       "%s:hid_hw_open\n",
+                       __func__);
+               goto hid_hw_open_fail;
+       }
+
        if (steam->quirks & STEAM_QUIRK_WIRELESS) {
-               ret = hid_hw_open(hdev);
-               if (ret) {
-                       hid_err(hdev,
-                               "%s:hid_hw_open for wireless\n",
-                               __func__);
-                       goto hid_hw_open_fail;
-               }
                hid_info(hdev, "Steam wireless receiver connected");
                steam_request_conn_status(steam);
        } else {
@@ -781,8 +769,8 @@ static int steam_probe(struct hid_device *hdev,
 
        return 0;
 
-hid_hw_open_fail:
 input_register_fail:
+hid_hw_open_fail:
 client_hdev_add_fail:
        hid_hw_stop(hdev);
 hid_hw_start_fail:
@@ -809,8 +797,8 @@ static void steam_remove(struct hid_device *hdev)
        cancel_work_sync(&steam->work_connect);
        if (steam->quirks & STEAM_QUIRK_WIRELESS) {
                hid_info(hdev, "Steam wireless receiver disconnected");
-               hid_hw_close(hdev);
        }
+       hid_hw_close(hdev);
        hid_hw_stop(hdev);
        steam_unregister(steam);
 }