Merge branch 'for-4.17/elecom' into for-linus
authorJiri Kosina <jkosina@suse.cz>
Thu, 5 Apr 2018 11:16:37 +0000 (13:16 +0200)
committerJiri Kosina <jkosina@suse.cz>
Thu, 5 Apr 2018 11:16:37 +0000 (13:16 +0200)
Support for new elecom device.

12 files changed:
Documentation/ABI/testing/sysfs-driver-hid-logitech-hidpp [new file with mode: 0644]
Documentation/ABI/testing/sysfs-driver-hid-ntrig [new file with mode: 0644]
drivers/hid/hid-core.c
drivers/hid/hid-corsair.c
drivers/hid/hid-ids.h
drivers/hid/hid-input.c
drivers/hid/hid-multitouch.c
drivers/hid/hid-quirks.c
drivers/hid/hid-rmi.c
drivers/hid/i2c-hid/i2c-hid.c
drivers/hid/wacom_sys.c
include/linux/hid.h

diff --git a/Documentation/ABI/testing/sysfs-driver-hid-logitech-hidpp b/Documentation/ABI/testing/sysfs-driver-hid-logitech-hidpp
new file mode 100644 (file)
index 0000000..d8f831f
--- /dev/null
@@ -0,0 +1,19 @@
+What:          /sys/bus/hid/drivers/logitech-hidpp-device/<dev>/range
+Date:          Jan, 2016
+KernelVersion: 4.6
+Contact:       linux-input@vger.kernel.org
+Description:
+               (RW) This attribute controls the amount of 'turn' permitted in
+               Logitech G920 wheel. Reading from the file shows the current
+               range of the steering wheel. Writing a value within the min and
+               max boundary sets the range of the wheel.
+
+What:          /sys/bus/hid/drivers/logitech-hidpp-device/<dev>/builtin_power_supply
+Date:          Apr, 2017
+KernelVersion: 4.12
+Contact:       linux-input@vger.kernel.org
+Description:
+               Presence of this file indicates that HID++ driver is capable of
+               handling battery properties in the kernel. This way, upower can
+               add a udev rule to decide whether or not it should use the
+               internal unifying support or the generic kernel one.
diff --git a/Documentation/ABI/testing/sysfs-driver-hid-ntrig b/Documentation/ABI/testing/sysfs-driver-hid-ntrig
new file mode 100644 (file)
index 0000000..e574a56
--- /dev/null
@@ -0,0 +1,70 @@
+What:          /sys/bus/hid/drivers/ntrig/<dev>/activate_slack
+Date:          May, 2010
+KernelVersion: 2.6.35
+Contact:       linux-input@vger.kernel.org
+Description:
+               (RW) Number of contact frames ignored before acknowledging the
+               start of activity (activating touch).
+
+
+What:          /sys/bus/hid/drivers/ntrig/<dev>/decativate_slack
+Date:          May, 2010
+KernelVersion: 2.6.35
+Contact:       linux-input@vger.kernel.org
+Description:
+               (RW) Number of empty (no contact) frames ignored before
+               acknowledging the end of activity (deactivating touch).
+
+               When the last finger is removed from the device, it sends a
+               number of empty frames. By holding off on deactivation for a few
+               frames false erroneous disconnects can be tolerated, where the
+               sensor may mistakenly not detect a finger that is still present.
+
+
+What:          /sys/bus/hid/drivers/ntrig/<dev>/activation_width
+What:          /sys/bus/hid/drivers/ntrig/<dev>/activation_height
+Date:          May, 2010
+KernelVersion: 2.6.35
+Contact:       linux-input@vger.kernel.org
+Description:
+               Threholds to override activation slack.
+
+               activation_width:       (RW) Width threshold to immediately
+                                       start processing touch events.
+
+               activation_height:      (RW) Height threshold to immediately
+                                       start processing touch events.
+
+
+What:          /sys/bus/hid/drivers/ntrig/<dev>/min_width
+What:          /sys/bus/hid/drivers/ntrig/<dev>/min_height
+Date:          May, 2010
+KernelVersion: 2.6.35
+Contact:       linux-input@vger.kernel.org
+Description:
+               Minimum size contact accepted.
+
+               min_width:      (RW) Minimum touch contact width to decide
+                               activation and activity.
+
+               min_height:     (RW) Minimum touch contact height to decide
+                               activation and activity.
+
+
+What:          /sys/bus/hid/drivers/ntrig/<dev>/sensor_physical_width
+What:          /sys/bus/hid/drivers/ntrig/<dev>/sensor_physical_height
+Date:          May, 2010
+KernelVersion: 2.6.35
+Contact:       linux-input@vger.kernel.org
+Description:
+               (RO) These are internal ranges not used for normal events but
+               useful for tuning.
+
+
+What:          /sys/bus/hid/drivers/ntrig/<dev>/sensor_logical_width
+What:          /sys/bus/hid/drivers/ntrig/<dev>/sensor_logical_height
+Date:          May, 2010
+KernelVersion: 2.6.35
+Contact:       linux-input@vger.kernel.org
+Description:
+               (RO) The range for positions reported during activity.
index c2560aa..4fc08c3 100644 (file)
@@ -1365,7 +1365,7 @@ u8 *hid_alloc_report_buf(struct hid_report *report, gfp_t flags)
         * of implement() working on 8 byte chunks
         */
 
-       int len = hid_report_len(report) + 7;
+       u32 len = hid_report_len(report) + 7;
 
        return kmalloc(len, flags);
 }
@@ -1430,7 +1430,7 @@ void __hid_request(struct hid_device *hid, struct hid_report *report,
 {
        char *buf;
        int ret;
-       int len;
+       u32 len;
 
        buf = hid_alloc_report_buf(report, GFP_KERNEL);
        if (!buf)
@@ -1456,14 +1456,14 @@ out:
 }
 EXPORT_SYMBOL_GPL(__hid_request);
 
-int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
+int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size,
                int interrupt)
 {
        struct hid_report_enum *report_enum = hid->report_enum + type;
        struct hid_report *report;
        struct hid_driver *hdrv;
        unsigned int a;
-       int rsize, csize = size;
+       u32 rsize, csize = size;
        u8 *cdata = data;
        int ret = 0;
 
@@ -1521,7 +1521,7 @@ EXPORT_SYMBOL_GPL(hid_report_raw_event);
  *
  * This is data entry for lower layers.
  */
-int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int interrupt)
+int hid_input_report(struct hid_device *hid, int type, u8 *data, u32 size, int interrupt)
 {
        struct hid_report_enum *report_enum;
        struct hid_driver *hdrv;
index 9ba5d98..ec9e060 100644 (file)
@@ -2,11 +2,14 @@
  * HID driver for Corsair devices
  *
  * Supported devices:
+ *  - Vengeance K70 Keyboard
+ *  - K70 RAPIDFIRE Keyboard
  *  - Vengeance K90 Keyboard
  *  - Scimitar PRO RGB Gaming Mouse
  *
  * Copyright (c) 2015 Clement Vuchener
  * Copyright (c) 2017 Oscar Campos
+ * Copyright (c) 2017 Aaron Bottegal
  */
 
 /*
@@ -673,7 +676,7 @@ static int corsair_input_mapping(struct hid_device *dev,
 }
 
 /*
- * The report descriptor of Corsair Scimitar RGB Pro gaming mouse is
+ * The report descriptor of some of the Corsair gaming mice is
  * non parseable as they define two consecutive Logical Minimum for
  * the Usage Page (Consumer) in rdescs bytes 75 and 77 being 77 0x16
  * that should be obviousy 0x26 for Logical Magimum of 16 bits. This
@@ -681,7 +684,8 @@ static int corsair_input_mapping(struct hid_device *dev,
  * Minimum being larger than Logical Maximum.
  *
  * This driver fixes the report descriptor for:
- * - USB ID b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse
+ * - USB ID 1b1c:1b34, sold as GLAIVE RGB Gaming mouse
+ * - USB ID 1b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse
  */
 
 static __u8 *corsair_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
@@ -691,13 +695,14 @@ static __u8 *corsair_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
 
        if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
                /*
-                * Corsair Scimitar RGB Pro report descriptor is broken and
-                * defines two different Logical Minimum for the Consumer
-                * Application. The byte 77 should be a 0x26 defining a 16
-                * bits integer for the Logical Maximum but it is a 0x16
+                * Corsair GLAIVE RGB and Scimitar RGB Pro report descriptor is
+                * broken and defines two different Logical Minimum for the
+                * Consumer Application. The byte 77 should be a 0x26 defining
+                * a 16 bits integer for the Logical Maximum but it is a 0x16
                 * instead (Logical Minimum)
                 */
                switch (hdev->product) {
+               case USB_DEVICE_ID_CORSAIR_GLAIVE_RGB:
                case USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB:
                        if (*rsize >= 172 && rdesc[75] == 0x15 && rdesc[77] == 0x16
                        && rdesc[78] == 0xff && rdesc[79] == 0x0f) {
@@ -715,8 +720,15 @@ static const struct hid_device_id corsair_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90),
                .driver_data = CORSAIR_USE_K90_MACRO |
                               CORSAIR_USE_K90_BACKLIGHT },
+       { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR,
+            USB_DEVICE_ID_CORSAIR_GLAIVE_RGB) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR,
             USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB) },
+       /*
+        * Vengeance K70 and K70 RAPIDFIRE share product IDs.
+        */
+       { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR,
+            USB_DEVICE_ID_CORSAIR_K70R) },
        {}
 };
 
index c8902f2..3fdd101 100644 (file)
 #define USB_DEVICE_ID_CORSAIR_K70RGB    0x1b13
 #define USB_DEVICE_ID_CORSAIR_STRAFE    0x1b15
 #define USB_DEVICE_ID_CORSAIR_K65RGB    0x1b17
+#define USB_DEVICE_ID_CORSAIR_GLAIVE_RGB        0x1b34
 #define USB_DEVICE_ID_CORSAIR_K70RGB_RAPIDFIRE  0x1b38
 #define USB_DEVICE_ID_CORSAIR_K65RGB_RAPIDFIRE  0x1b39
 #define USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB  0x1b3e
index 04d01b5..d863987 100644 (file)
@@ -1368,7 +1368,8 @@ static void hidinput_led_worker(struct work_struct *work)
                                              led_work);
        struct hid_field *field;
        struct hid_report *report;
-       int len, ret;
+       int ret;
+       u32 len;
        __u8 *buf;
 
        field = hidinput_get_led_field(hid);
index 3b4739b..2e1736b 100644 (file)
@@ -370,7 +370,8 @@ static const struct attribute_group mt_attribute_group = {
 static void mt_get_feature(struct hid_device *hdev, struct hid_report *report)
 {
        struct mt_device *td = hid_get_drvdata(hdev);
-       int ret, size = hid_report_len(report);
+       int ret;
+       u32 size = hid_report_len(report);
        u8 *buf;
 
        /*
@@ -1183,7 +1184,7 @@ static void mt_set_input_mode(struct hid_device *hdev)
        struct hid_report_enum *re;
        struct mt_class *cls = &td->mtclass;
        char *buf;
-       int report_len;
+       u32 report_len;
 
        if (td->inputmode < 0)
                return;
index 91049df..a67c599 100644 (file)
@@ -62,6 +62,7 @@ static const struct hid_device_id hid_quirks[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70R), HID_QUIRK_NO_INIT_REPORTS },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K95RGB), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_M65RGB), HID_QUIRK_NO_INIT_REPORTS },
+       { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_GLAIVE_RGB), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_STRAFE), HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
        { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51), HID_QUIRK_NOGET },
@@ -317,6 +318,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
 #endif
 #if IS_ENABLED(CONFIG_HID_CORSAIR)
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_GLAIVE_RGB) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB) },
 #endif
 #if IS_ENABLED(CONFIG_HID_CP2112)
index c6c05df..9c93621 100644 (file)
@@ -89,8 +89,8 @@ struct rmi_data {
        u8 *writeReport;
        u8 *readReport;
 
-       int input_report_size;
-       int output_report_size;
+       u32 input_report_size;
+       u32 output_report_size;
 
        unsigned long flags;
 
index 7230243..e6f413a 100644 (file)
@@ -144,10 +144,10 @@ struct i2c_hid {
                                                   * register of the HID
                                                   * descriptor. */
        unsigned int            bufsize;        /* i2c buffer size */
-       char                    *inbuf;         /* Input buffer */
-       char                    *rawbuf;        /* Raw Input buffer */
-       char                    *cmdbuf;        /* Command buffer */
-       char                    *argsbuf;       /* Command arguments buffer */
+       u8                      *inbuf;         /* Input buffer */
+       u8                      *rawbuf;        /* Raw Input buffer */
+       u8                      *cmdbuf;        /* Command buffer */
+       u8                      *argsbuf;       /* Command arguments buffer */
 
        unsigned long           flags;          /* device flags */
        unsigned long           quirks;         /* Various quirks */
@@ -455,7 +455,8 @@ out_unlock:
 
 static void i2c_hid_get_input(struct i2c_hid *ihid)
 {
-       int ret, ret_size;
+       int ret;
+       u32 ret_size;
        int size = le16_to_cpu(ihid->hdesc.wMaxInputLength);
 
        if (size > ihid->bufsize)
@@ -480,7 +481,7 @@ static void i2c_hid_get_input(struct i2c_hid *ihid)
                return;
        }
 
-       if (ret_size > size) {
+       if ((ret_size > size) || (ret_size <= 2)) {
                dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
                        __func__, size, ret_size);
                return;
index 4095431..b54ef1f 100644 (file)
@@ -219,7 +219,7 @@ static void wacom_feature_mapping(struct hid_device *hdev,
        unsigned int equivalent_usage = wacom_equivalent_usage(usage->hid);
        u8 *data;
        int ret;
-       int n;
+       u32 n;
 
        switch (equivalent_usage) {
        case HID_DG_CONTACTMAX:
@@ -519,7 +519,7 @@ static int wacom_set_device_mode(struct hid_device *hdev,
        u8 *rep_data;
        struct hid_report *r;
        struct hid_report_enum *re;
-       int length;
+       u32 length;
        int error = -ENOMEM, limit = 0;
 
        if (wacom_wac->mode_report < 0)
index 091a81c..0efe80b 100644 (file)
@@ -851,7 +851,7 @@ extern int hidinput_connect(struct hid_device *hid, unsigned int force);
 extern void hidinput_disconnect(struct hid_device *);
 
 int hid_set_field(struct hid_field *, unsigned, __s32);
-int hid_input_report(struct hid_device *, int type, u8 *, int, int);
+int hid_input_report(struct hid_device *, int type, u8 *, u32, int);
 int hidinput_find_field(struct hid_device *hid, unsigned int type, unsigned int code, struct hid_field **field);
 struct hid_field *hidinput_get_led_field(struct hid_device *hid);
 unsigned int hidinput_count_leds(struct hid_device *hid);
@@ -1102,13 +1102,13 @@ static inline void hid_hw_wait(struct hid_device *hdev)
  *
  * @report: the report we want to know the length
  */
-static inline int hid_report_len(struct hid_report *report)
+static inline u32 hid_report_len(struct hid_report *report)
 {
        /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */
        return ((report->size - 1) >> 3) + 1 + (report->id > 0);
 }
 
-int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,
+int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, u32 size,
                int interrupt);
 
 /* HID quirks API */