Merge branches 'for-4.11/upstream-fixes', 'for-4.12/accutouch', 'for-4.12/cp2112...
authorJiri Kosina <jkosina@suse.cz>
Tue, 2 May 2017 09:01:10 +0000 (11:01 +0200)
committerJiri Kosina <jkosina@suse.cz>
Tue, 2 May 2017 09:01:10 +0000 (11:01 +0200)
28 files changed:
Documentation/admin-guide/kernel-parameters.txt
Documentation/devicetree/bindings/input/hid-over-i2c.txt
drivers/hid/Kconfig
drivers/hid/Makefile
drivers/hid/hid-accutouch.c [new file with mode: 0644]
drivers/hid/hid-chicony.c
drivers/hid/hid-core.c
drivers/hid/hid-corsair.c
drivers/hid/hid-cp2112.c
drivers/hid/hid-debug.c
drivers/hid/hid-ids.h
drivers/hid/hid-input.c
drivers/hid/hid-logitech-dj.c
drivers/hid/hid-logitech-hidpp.c
drivers/hid/hid-multitouch.c
drivers/hid/hid-nti.c [new file with mode: 0644]
drivers/hid/hid-sony.c
drivers/hid/hid-uclogic.c
drivers/hid/hid-xinmo.c
drivers/hid/i2c-hid/i2c-hid.c
drivers/hid/usbhid/hid-core.c
drivers/hid/usbhid/hid-quirks.c
drivers/hid/usbhid/hiddev.c
drivers/hid/wacom_sys.c
drivers/hid/wacom_wac.c
include/linux/hid.h
include/linux/hiddev.h
include/linux/i2c/i2c-hid.h

index 635d11135090cd7fc604c2c3496359a5b7a50f73..14ffef04113c096f9ce2840bf8c0485c81e3e86a 100644 (file)
        usbhid.mousepoll=
                        [USBHID] The interval which mice are to be polled at.
 
+       usbhid.jspoll=
+                       [USBHID] The interval which joysticks are to be polled at.
+
        usb-storage.delay_use=
                        [UMS] The delay in seconds before a new device is
                        scanned for Logical Units (default 1).
index 488edcb264c4fea49441bb21ea7deb02a0056882..28e8bd8b7d640b34dceadae6b7fe5cf36d392527 100644 (file)
@@ -17,6 +17,22 @@ Required properties:
 - interrupt-parent: the phandle for the interrupt controller
 - interrupts: interrupt line
 
+Additional optional properties:
+
+Some devices may support additional optional properties to help with, e.g.,
+power sequencing. The following properties can be supported by one or more
+device-specific compatible properties, which should be used in addition to the
+"hid-over-i2c" string.
+
+- compatible:
+  * "wacom,w9013" (Wacom W9013 digitizer). Supports:
+    - vdd-supply
+    - post-power-on-delay-ms
+
+- vdd-supply: phandle of the regulator that provides the supply voltage.
+- post-power-on-delay-ms: time required by the device after enabling its regulators
+  before it is ready for communication. Must be used with 'vdd-supply'.
+
 Example:
 
        i2c-hid-dev@2c {
index 1aeb80e5242461830f1d4075f0fb59bcb6ddc898..816679150b3510bf928683750d09ec97dc6c3194 100644 (file)
@@ -98,6 +98,18 @@ config HID_A4TECH
        ---help---
        Support for A4 tech X5 and WOP-35 / Trust 450L mice.
 
+config HID_ACCUTOUCH
+       tristate "Accutouch touch device"
+       depends on USB_HID
+       ---help---
+         This selects a driver for the Accutouch 2216 touch controller.
+
+         The driver works around a problem in the reported device capabilities
+         which causes userspace to detect the device as a mouse rather than
+          a touchscreen.
+
+         Say Y here if you have a Accutouch 2216 touch controller.
+
 config HID_ACRUX
        tristate "ACRUX game controller support"
        depends on HID
@@ -175,11 +187,11 @@ config HID_CHERRY
        Support for Cherry Cymotion keyboard.
 
 config HID_CHICONY
-       tristate "Chicony Tactical pad"
+       tristate "Chicony devices"
        depends on HID
        default !EXPERT
        ---help---
-       Support for Chicony Tactical pad.
+       Support for Chicony Tactical pad and special keys on Chicony keyboards.
 
 config HID_CORSAIR
        tristate "Corsair devices"
@@ -190,6 +202,7 @@ config HID_CORSAIR
 
        Supported devices:
        - Vengeance K90
+       - Scimitar PRO RGB
 
 config HID_PRODIKEYS
        tristate "Prodikeys PC-MIDI Keyboard support"
@@ -214,7 +227,8 @@ config HID_CMEDIA
 
 config HID_CP2112
        tristate "Silicon Labs CP2112 HID USB-to-SMBus Bridge support"
-       depends on USB_HID && I2C && GPIOLIB && GPIOLIB_IRQCHIP
+       depends on USB_HID && I2C && GPIOLIB
+       select GPIOLIB_IRQCHIP
        ---help---
        Support for Silicon Labs CP2112 HID USB to SMBus Master Bridge.
        This is a HID device driver which registers as an i2c adapter
@@ -440,6 +454,7 @@ config HID_LOGITECH_DJ
 config HID_LOGITECH_HIDPP
        tristate "Logitech HID++ devices support"
        depends on HID_LOGITECH
+       select POWER_SUPPLY
        ---help---
        Support for Logitech devices relyingon the HID++ Logitech specification
 
@@ -580,6 +595,12 @@ config HID_MULTITOUCH
          To compile this driver as a module, choose M here: the
          module will be called hid-multitouch.
 
+config HID_NTI
+       tristate "NTI keyboard adapters"
+       ---help---
+       Support for the "extra" Sun keyboard keys on keyboards attached
+       through Network Technologies USB-SUN keyboard adapters.
+
 config HID_NTRIG
        tristate "N-Trig touch screen"
        depends on USB_HID
index 4d111f23e801c28151a58a7e6745d8332758db76..fef027bc7fa3b17b6cd337c7d2460bd3245314d9 100644 (file)
@@ -21,6 +21,7 @@ hid-wiimote-y         := hid-wiimote-core.o hid-wiimote-modules.o
 hid-wiimote-$(CONFIG_DEBUG_FS) += hid-wiimote-debug.o
 
 obj-$(CONFIG_HID_A4TECH)       += hid-a4tech.o
+obj-$(CONFIG_HID_ACCUTOUCH)    += hid-accutouch.o
 obj-$(CONFIG_HID_ALPS)         += hid-alps.o
 obj-$(CONFIG_HID_ACRUX)                += hid-axff.o
 obj-$(CONFIG_HID_APPLE)                += hid-apple.o
@@ -62,6 +63,7 @@ obj-$(CONFIG_HID_MAYFLASH)    += hid-mf.o
 obj-$(CONFIG_HID_MICROSOFT)    += hid-microsoft.o
 obj-$(CONFIG_HID_MONTEREY)     += hid-monterey.o
 obj-$(CONFIG_HID_MULTITOUCH)   += hid-multitouch.o
+obj-$(CONFIG_HID_NTI)                  += hid-nti.o
 obj-$(CONFIG_HID_NTRIG)                += hid-ntrig.o
 obj-$(CONFIG_HID_ORTEK)                += hid-ortek.o
 obj-$(CONFIG_HID_PRODIKEYS)    += hid-prodikeys.o
diff --git a/drivers/hid/hid-accutouch.c b/drivers/hid/hid-accutouch.c
new file mode 100644 (file)
index 0000000..4e28716
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * HID driver for Elo Accutouch touchscreens
+ *
+ * Copyright (c) 2016, Collabora Ltd.
+ * Copyright (c) 2016, General Electric Company
+ *
+ * based on hid-penmount.c
+ *  Copyright (c) 2014 Christian Gmeiner <christian.gmeiner <at> gmail.com>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/hid.h>
+#include <linux/module.h>
+#include "hid-ids.h"
+
+static int accutouch_input_mapping(struct hid_device *hdev,
+                                  struct hid_input *hi,
+                                  struct hid_field *field,
+                                  struct hid_usage *usage,
+                                  unsigned long **bit, int *max)
+{
+       if ((usage->hid & HID_USAGE_PAGE) == HID_UP_BUTTON) {
+               hid_map_usage(hi, usage, bit, max, EV_KEY, BTN_TOUCH);
+               return 1;
+       }
+
+       return 0;
+}
+
+static const struct hid_device_id accutouch_devices[] = {
+       { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) },
+       { }
+};
+MODULE_DEVICE_TABLE(hid, accutouch_devices);
+
+static struct hid_driver accutouch_driver = {
+       .name = "hid-accutouch",
+       .id_table = accutouch_devices,
+       .input_mapping = accutouch_input_mapping,
+};
+
+module_hid_driver(accutouch_driver);
+
+MODULE_AUTHOR("Martyn Welch <martyn.welch@collabora.co.uk");
+MODULE_DESCRIPTION("Elo Accutouch HID TouchScreen driver");
+MODULE_LICENSE("GPL");
index bc3cec199feefdf437d0c0141c5ff6f73aa10308..f04ed9aabc3f9fea0baf5b074acd83b6d07527c6 100644 (file)
@@ -86,6 +86,7 @@ static const struct hid_device_id ch_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_WIRELESS2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_JESS_ZEN_AIO_KBD) },
        { }
 };
 MODULE_DEVICE_TABLE(hid, ch_devices);
index e9e87d337446918f672771551f41041755d83d22..cd6eba051b97e2de8b8489545a60935f9237d304 100644 (file)
@@ -819,8 +819,7 @@ static int hid_scan_report(struct hid_device *hid)
                hid->group = HID_GROUP_WACOM;
                break;
        case USB_VENDOR_ID_SYNAPTICS:
-               if (hid->group == HID_GROUP_GENERIC ||
-                   hid->group == HID_GROUP_MULTITOUCH_WIN_8)
+               if (hid->group == HID_GROUP_GENERIC)
                        if ((parser->scan_flags & HID_SCAN_FLAG_VENDOR_SPECIFIC)
                            && (parser->scan_flags & HID_SCAN_FLAG_GD_POINTER))
                                /*
@@ -1695,7 +1694,7 @@ int hid_connect(struct hid_device *hdev, unsigned int connect_mask)
                len += sprintf(buf + len, "input");
        if (hdev->claimed & HID_CLAIMED_HIDDEV)
                len += sprintf(buf + len, "%shiddev%d", len ? "," : "",
-                               hdev->minor);
+                               ((struct hiddev *)hdev->hiddev)->minor);
        if (hdev->claimed & HID_CLAIMED_HIDRAW)
                len += sprintf(buf + len, "%shidraw%d", len ? "," : "",
                                ((struct hidraw *)hdev->hidraw)->minor);
@@ -1870,6 +1869,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_AK1D) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CHICONY, USB_DEVICE_ID_CHICONY_ACER_SWITCH12) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K90) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_PRODIKEYS_PCMIDI) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CYGNAL, USB_DEVICE_ID_CYGNAL_CP2112) },
        { HID_USB_DEVICE(USB_VENDOR_ID_CYPRESS, USB_DEVICE_ID_CYPRESS_BARCODE_1) },
@@ -1891,6 +1891,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ELECOM, USB_DEVICE_ID_ELECOM_BM084) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0009) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ELO, 0x0030) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_ELO, USB_DEVICE_ID_ELO_ACCUTOUCH_2216) },
        { HID_USB_DEVICE(USB_VENDOR_ID_EMS, USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II) },
        { HID_USB_DEVICE(USB_VENDOR_ID_EZKEY, USB_DEVICE_ID_BTC_8193) },
        { HID_USB_DEVICE(USB_VENDOR_ID_GAMERON, USB_DEVICE_ID_GAMERON_DUAL_PSX_ADAPTOR) },
@@ -1910,6 +1911,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A081) },
        { HID_USB_DEVICE(USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_MOUSE_A0C2) },
        { HID_USB_DEVICE(USB_VENDOR_ID_HUION, USB_DEVICE_ID_HUION_TABLET) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_JESS, USB_DEVICE_ID_JESS_ZEN_AIO_KBD) },
        { HID_USB_DEVICE(USB_VENDOR_ID_JESS2, USB_DEVICE_ID_JESS2_COLOR_RUMBLE_PAD) },
        { HID_BLUETOOTH_DEVICE(USB_VENDOR_ID_ION, USB_DEVICE_ID_ICADE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_KENSINGTON, USB_DEVICE_ID_KS_SLIMBLADE) },
@@ -1990,6 +1992,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_MICROSOFT, USB_DEVICE_ID_MS_POWER_COVER) },
        { HID_USB_DEVICE(USB_VENDOR_ID_MONTEREY, USB_DEVICE_ID_GENIUS_KB29E) },
        { HID_USB_DEVICE(USB_VENDOR_ID_MSI, USB_DEVICE_ID_MSI_GT683R_LED_PANEL) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_NTI, USB_DEVICE_ID_USB_SUN) },
        { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN) },
        { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1) },
        { HID_USB_DEVICE(USB_VENDOR_ID_NTRIG, USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_2) },
@@ -2094,6 +2097,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) },
        { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) },
        { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) },
        { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SMARTJOY_PLUS) },
        { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_SUPER_JOY_BOX_3) },
        { HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_DUAL_USB_JOYPAD) },
@@ -2110,6 +2114,7 @@ static const struct hid_device_id hid_have_special_driver[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_WALTOP, USB_DEVICE_ID_WALTOP_SIRIUS_BATTERY_FREE_TABLET) },
        { HID_USB_DEVICE(USB_VENDOR_ID_X_TENSIONS, USB_DEVICE_ID_SPEEDLINK_VAD_CEZANNE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_THT_2P_ARCADE) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0005) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ZEROPLUS, 0x0030) },
        { HID_USB_DEVICE(USB_VENDOR_ID_ZYDACRON, USB_DEVICE_ID_ZYDACRON_REMOTE_CONTROL) },
index c0303f61c26a94f1998f6883d42a0fc8cb41f432..9ba5d98a118042a52dc40b895c3b2e8df67c0b39 100644 (file)
@@ -3,8 +3,10 @@
  *
  * Supported devices:
  *  - Vengeance K90 Keyboard
+ *  - Scimitar PRO RGB Gaming Mouse
  *
  * Copyright (c) 2015 Clement Vuchener
+ * Copyright (c) 2017 Oscar Campos
  */
 
 /*
@@ -670,10 +672,51 @@ static int corsair_input_mapping(struct hid_device *dev,
        return 0;
 }
 
+/*
+ * The report descriptor of Corsair Scimitar RGB Pro gaming mouse 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
+ * prevents poper parsing of the report descriptor due Logical
+ * Minimum being larger than Logical Maximum.
+ *
+ * This driver fixes the report descriptor for:
+ * - USB ID b1c:1b3e, sold as Scimitar RGB Pro Gaming mouse
+ */
+
+static __u8 *corsair_mouse_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+        unsigned int *rsize)
+{
+       struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
+
+       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
+                * instead (Logical Minimum)
+                */
+               switch (hdev->product) {
+               case USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB:
+                       if (*rsize >= 172 && rdesc[75] == 0x15 && rdesc[77] == 0x16
+                       && rdesc[78] == 0xff && rdesc[79] == 0x0f) {
+                               hid_info(hdev, "Fixing up report descriptor\n");
+                               rdesc[77] = 0x26;
+                       }
+                       break;
+               }
+
+       }
+       return rdesc;
+}
+
 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_SCIMITAR_PRO_RGB) },
        {}
 };
 
@@ -686,10 +729,14 @@ static struct hid_driver corsair_driver = {
        .event = corsair_event,
        .remove = corsair_remove,
        .input_mapping = corsair_input_mapping,
+       .report_fixup = corsair_mouse_report_fixup,
 };
 
 module_hid_driver(corsair_driver);
 
 MODULE_LICENSE("GPL");
+/* Original K90 driver author */
 MODULE_AUTHOR("Clement Vuchener");
+/* Scimitar PRO RGB driver author */
+MODULE_AUTHOR("Oscar Campos");
 MODULE_DESCRIPTION("HID driver for Corsair devices");
index b22d0f83f8e38a9ee0d0eb7381e95d6b90442b61..078026f63b6f40999a2aa1feb8023d3905a6044c 100644 (file)
@@ -27,6 +27,7 @@
 #include <linux/gpio.h>
 #include <linux/gpio/driver.h>
 #include <linux/hid.h>
+#include <linux/hidraw.h>
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/nls.h>
@@ -1297,7 +1298,8 @@ static int cp2112_probe(struct hid_device *hdev, const struct hid_device_id *id)
        dev->adap.algo_data     = dev;
        dev->adap.dev.parent    = &hdev->dev;
        snprintf(dev->adap.name, sizeof(dev->adap.name),
-                "CP2112 SMBus Bridge on hiddev%d", hdev->minor);
+                "CP2112 SMBus Bridge on hidraw%d",
+                ((struct hidraw *)hdev->hidraw)->minor);
        dev->hwversion = buf[2];
        init_waitqueue_head(&dev->wait);
 
index acfb522a432ae51ff16d0a475783eed167969d7c..5a0061c0ee87a7f3c242345bec24b9f5fb829bf4 100644 (file)
@@ -140,9 +140,11 @@ static const struct hid_usage_entry hid_usage_table[] = {
     {0, 0x03, "LightPen"},
     {0, 0x04, "TouchScreen"},
     {0, 0x05, "TouchPad"},
+    {0, 0x0e, "DeviceConfiguration"},
     {0, 0x20, "Stylus"},
     {0, 0x21, "Puck"},
     {0, 0x22, "Finger"},
+    {0, 0x23, "DeviceSettings"},
     {0, 0x30, "TipPressure"},
     {0, 0x31, "BarrelPressure"},
     {0, 0x32, "InRange"},
index 86c95d30ac801f2895caef97a575955289d352a4..4b07a467d7a3574c5f4c84ee58e699ae43135ec3 100644 (file)
 #define USB_DEVICE_ID_ATEN_4PORTKVMC   0x2208
 #define USB_DEVICE_ID_ATEN_CS682       0x2213
 #define USB_DEVICE_ID_ATEN_CS692       0x8021
+#define USB_DEVICE_ID_ATEN_CS1758      0x2220
 
 #define USB_VENDOR_ID_ATMEL            0x03eb
 #define USB_DEVICE_ID_ATMEL_MULTITOUCH 0x211c
 #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_K70RGB_RAPIDFIRE  0x1b38
+#define USB_DEVICE_ID_CORSAIR_K65RGB_RAPIDFIRE  0x1b39
+#define USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB  0x1b3e
 
 #define USB_VENDOR_ID_CREATIVELABS     0x041e
 #define USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51     0x322c
 #define USB_VENDOR_ID_ELO              0x04E7
 #define USB_DEVICE_ID_ELO_TS2515       0x0022
 #define USB_DEVICE_ID_ELO_TS2700       0x0020
+#define USB_DEVICE_ID_ELO_ACCUTOUCH_2216       0x0050
 
 #define USB_VENDOR_ID_EMS              0x2006
 #define USB_DEVICE_ID_EMS_TRIO_LINKER_PLUS_II 0x0118
 #define USB_VENDOR_ID_IRTOUCHSYSTEMS   0x6615
 #define USB_DEVICE_ID_IRTOUCH_INFRARED_USB     0x0070
 
+#define USB_VENDOR_ID_INNOMEDIA                        0x1292
+#define USB_DEVICE_ID_INNEX_GENESIS_ATARI      0x4745
+
 #define USB_VENDOR_ID_ITE               0x048d
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA   0x8386
 #define USB_DEVICE_ID_ITE_LENOVO_YOGA2  0x8350
 
 #define USB_VENDOR_ID_JESS             0x0c45
 #define USB_DEVICE_ID_JESS_YUREX       0x1010
+#define USB_DEVICE_ID_JESS_ZEN_AIO_KBD 0x5112
 
 #define USB_VENDOR_ID_JESS2            0x0f30
 #define USB_DEVICE_ID_JESS2_COLOR_RUMBLE_PAD 0x0111
 #define USB_DEVICE_ID_NOVATEK_PCT      0x0600
 #define USB_DEVICE_ID_NOVATEK_MOUSE    0x1602
 
+#define USB_VENDOR_ID_NTI               0x0757
+#define USB_DEVICE_ID_USB_SUN           0x0a00
+
 #define USB_VENDOR_ID_NTRIG            0x1b96
 #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN   0x0001
 #define USB_DEVICE_ID_NTRIG_TOUCH_SCREEN_1   0x0003
 #define USB_DEVICE_ID_UGEE_TABLET_45           0x0045
 #define USB_DEVICE_ID_YIYNOVA_TABLET           0x004d
 
+#define USB_VENDOR_ID_UGEE             0x28bd
+#define USB_DEVICE_ID_UGEE_TABLET_EX07S                0x0071
+
 #define USB_VENDOR_ID_UNITEC   0x227d
 #define USB_DEVICE_ID_UNITEC_USB_TOUCH_0709    0x0709
 #define USB_DEVICE_ID_UNITEC_USB_TOUCH_0A19    0x0a19
 
 #define USB_VENDOR_ID_XIN_MO                   0x16c0
 #define USB_DEVICE_ID_XIN_MO_DUAL_ARCADE       0x05e1
+#define USB_DEVICE_ID_THT_2P_ARCADE            0x75e1
 
 #define USB_VENDOR_ID_XIROKU           0x1477
 #define USB_DEVICE_ID_XIROKU_SPX       0x1006
index d05f903c7614530625d9adc696cdc7f3661abe15..a1ebdd7d4d4d01c7942beb9e988a6fb36dd94714 100644 (file)
@@ -1150,18 +1150,26 @@ void hidinput_hid_event(struct hid_device *hid, struct hid_field *field, struct
 
        /*
         * Ignore out-of-range values as per HID specification,
-        * section 5.10 and 6.2.25.
+        * section 5.10 and 6.2.25, when NULL state bit is present.
+        * When it's not, clamp the value to match Microsoft's input
+        * driver as mentioned in "Required HID usages for digitizers":
+        * https://msdn.microsoft.com/en-us/library/windows/hardware/dn672278(v=vs.85).asp
         *
         * The logical_minimum < logical_maximum check is done so that we
         * don't unintentionally discard values sent by devices which
         * don't specify logical min and max.
         */
        if ((field->flags & HID_MAIN_ITEM_VARIABLE) &&
-           (field->logical_minimum < field->logical_maximum) &&
-           (value < field->logical_minimum ||
-            value > field->logical_maximum)) {
-               dbg_hid("Ignoring out-of-range value %x\n", value);
-               return;
+           (field->logical_minimum < field->logical_maximum)) {
+               if (field->flags & HID_MAIN_ITEM_NULL_STATE &&
+                   (value < field->logical_minimum ||
+                    value > field->logical_maximum)) {
+                       dbg_hid("Ignoring out-of-range value %x\n", value);
+                       return;
+               }
+               value = clamp(value,
+                             field->logical_minimum,
+                             field->logical_maximum);
        }
 
        /*
index 5bc6d80d5be79f465f3cbbb686c471db6162eb63..826fa1e1c8d985fb65a2af973c43568c043c6949 100644 (file)
@@ -692,8 +692,12 @@ static void logi_dj_ll_close(struct hid_device *hid)
        dbg_hid("%s:%s\n", __func__, hid->phys);
 }
 
-static u8 unifying_name_query[]  = {0x10, 0xff, 0x83, 0xb5, 0x40, 0x00, 0x00};
-static u8 unifying_name_answer[] = {0x11, 0xff, 0x83, 0xb5};
+/*
+ * Register 0xB5 is "pairing information". It is solely intended for the
+ * receiver, so do not overwrite the device index.
+ */
+static u8 unifying_pairing_query[]  = {0x10, 0xff, 0x83, 0xb5};
+static u8 unifying_pairing_answer[] = {0x11, 0xff, 0x83, 0xb5};
 
 static int logi_dj_ll_raw_request(struct hid_device *hid,
                                  unsigned char reportnum, __u8 *buf,
@@ -712,9 +716,9 @@ static int logi_dj_ll_raw_request(struct hid_device *hid,
 
                /* special case where we should not overwrite
                 * the device_index */
-               if (count == 7 && !memcmp(buf, unifying_name_query,
-                                         sizeof(unifying_name_query)))
-                       buf[4] |= djdev->device_index - 1;
+               if (count == 7 && !memcmp(buf, unifying_pairing_query,
+                                         sizeof(unifying_pairing_query)))
+                       buf[4] = (buf[4] & 0xf0) | (djdev->device_index - 1);
                else
                        buf[1] = djdev->device_index;
                return hid_hw_raw_request(djrcv_dev->hdev, reportnum, buf,
@@ -911,9 +915,8 @@ static int logi_dj_hidpp_event(struct hid_device *hdev,
                /* special case were the device wants to know its unifying
                 * name */
                if (size == HIDPP_REPORT_LONG_LENGTH &&
-                   !memcmp(data, unifying_name_answer,
-                           sizeof(unifying_name_answer)) &&
-                   ((data[4] & 0xF0) == 0x40))
+                   !memcmp(data, unifying_pairing_answer,
+                           sizeof(unifying_pairing_answer)))
                        device_index = (data[4] & 0x0F) + 1;
                else
                        return false;
index 2e2515a4c070eac305a834c9229d0e1fa27f722f..41b39464ded87f6ee3a4b0b302e0df52feddc520 100644 (file)
@@ -56,15 +56,21 @@ MODULE_PARM_DESC(disable_tap_to_click,
 #define HIDPP_QUIRK_CLASS_M560                 BIT(1)
 #define HIDPP_QUIRK_CLASS_K400                 BIT(2)
 #define HIDPP_QUIRK_CLASS_G920                 BIT(3)
+#define HIDPP_QUIRK_CLASS_K750                 BIT(4)
 
 /* bits 2..20 are reserved for classes */
-#define HIDPP_QUIRK_CONNECT_EVENTS             BIT(21)
+/* #define HIDPP_QUIRK_CONNECT_EVENTS          BIT(21) disabled */
 #define HIDPP_QUIRK_WTP_PHYSICAL_BUTTONS       BIT(22)
 #define HIDPP_QUIRK_NO_HIDINPUT                        BIT(23)
 #define HIDPP_QUIRK_FORCE_OUTPUT_REPORTS       BIT(24)
+#define HIDPP_QUIRK_UNIFYING                   BIT(25)
 
-#define HIDPP_QUIRK_DELAYED_INIT               (HIDPP_QUIRK_NO_HIDINPUT | \
-                                                HIDPP_QUIRK_CONNECT_EVENTS)
+#define HIDPP_QUIRK_DELAYED_INIT               HIDPP_QUIRK_NO_HIDINPUT
+
+#define HIDPP_CAPABILITY_HIDPP10_BATTERY       BIT(0)
+#define HIDPP_CAPABILITY_HIDPP20_BATTERY       BIT(1)
+#define HIDPP_CAPABILITY_BATTERY_MILEAGE       BIT(2)
+#define HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS  BIT(3)
 
 /*
  * There are two hidpp protocols in use, the first version hidpp10 is known
@@ -110,6 +116,18 @@ struct hidpp_report {
        };
 } __packed;
 
+struct hidpp_battery {
+       u8 feature_index;
+       u8 solar_feature_index;
+       struct power_supply_desc desc;
+       struct power_supply *ps;
+       char name[64];
+       int status;
+       int capacity;
+       int level;
+       bool online;
+};
+
 struct hidpp_device {
        struct hid_device *hid_dev;
        struct mutex send_mutex;
@@ -128,8 +146,10 @@ struct hidpp_device {
        struct input_dev *delayed_input;
 
        unsigned long quirks;
-};
+       unsigned long capabilities;
 
+       struct hidpp_battery battery;
+};
 
 /* HID++ 1.0 error codes */
 #define HIDPP_ERROR                            0x8f
@@ -380,15 +400,220 @@ static void hidpp_prefix_name(char **name, int name_length)
 #define HIDPP_SET_LONG_REGISTER                                0x82
 #define HIDPP_GET_LONG_REGISTER                                0x83
 
+#define HIDPP_REG_GENERAL                              0x00
+
+static int hidpp10_enable_battery_reporting(struct hidpp_device *hidpp_dev)
+{
+       struct hidpp_report response;
+       int ret;
+       u8 params[3] = { 0 };
+
+       ret = hidpp_send_rap_command_sync(hidpp_dev,
+                                       REPORT_ID_HIDPP_SHORT,
+                                       HIDPP_GET_REGISTER,
+                                       HIDPP_REG_GENERAL,
+                                       NULL, 0, &response);
+       if (ret)
+               return ret;
+
+       memcpy(params, response.rap.params, 3);
+
+       /* Set the battery bit */
+       params[0] |= BIT(4);
+
+       return hidpp_send_rap_command_sync(hidpp_dev,
+                                       REPORT_ID_HIDPP_SHORT,
+                                       HIDPP_SET_REGISTER,
+                                       HIDPP_REG_GENERAL,
+                                       params, 3, &response);
+}
+
+#define HIDPP_REG_BATTERY_STATUS                       0x07
+
+static int hidpp10_battery_status_map_level(u8 param)
+{
+       int level;
+
+       switch (param) {
+       case 1 ... 2:
+               level = POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
+               break;
+       case 3 ... 4:
+               level = POWER_SUPPLY_CAPACITY_LEVEL_LOW;
+               break;
+       case 5 ... 6:
+               level = POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
+               break;
+       case 7:
+               level = POWER_SUPPLY_CAPACITY_LEVEL_HIGH;
+               break;
+       default:
+               level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN;
+       }
+
+       return level;
+}
+
+static int hidpp10_battery_status_map_status(u8 param)
+{
+       int status;
+
+       switch (param) {
+       case 0x00:
+               /* discharging (in use) */
+               status = POWER_SUPPLY_STATUS_DISCHARGING;
+               break;
+       case 0x21: /* (standard) charging */
+       case 0x24: /* fast charging */
+       case 0x25: /* slow charging */
+               status = POWER_SUPPLY_STATUS_CHARGING;
+               break;
+       case 0x26: /* topping charge */
+       case 0x22: /* charge complete */
+               status = POWER_SUPPLY_STATUS_FULL;
+               break;
+       case 0x20: /* unknown */
+               status = POWER_SUPPLY_STATUS_UNKNOWN;
+               break;
+       /*
+        * 0x01...0x1F = reserved (not charging)
+        * 0x23 = charging error
+        * 0x27..0xff = reserved
+        */
+       default:
+               status = POWER_SUPPLY_STATUS_NOT_CHARGING;
+               break;
+       }
+
+       return status;
+}
+
+static int hidpp10_query_battery_status(struct hidpp_device *hidpp)
+{
+       struct hidpp_report response;
+       int ret, status;
+
+       ret = hidpp_send_rap_command_sync(hidpp,
+                                       REPORT_ID_HIDPP_SHORT,
+                                       HIDPP_GET_REGISTER,
+                                       HIDPP_REG_BATTERY_STATUS,
+                                       NULL, 0, &response);
+       if (ret)
+               return ret;
+
+       hidpp->battery.level =
+               hidpp10_battery_status_map_level(response.rap.params[0]);
+       status = hidpp10_battery_status_map_status(response.rap.params[1]);
+       hidpp->battery.status = status;
+       /* the capacity is only available when discharging or full */
+       hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING ||
+                               status == POWER_SUPPLY_STATUS_FULL;
+
+       return 0;
+}
+
+#define HIDPP_REG_BATTERY_MILEAGE                      0x0D
+
+static int hidpp10_battery_mileage_map_status(u8 param)
+{
+       int status;
+
+       switch (param >> 6) {
+       case 0x00:
+               /* discharging (in use) */
+               status = POWER_SUPPLY_STATUS_DISCHARGING;
+               break;
+       case 0x01: /* charging */
+               status = POWER_SUPPLY_STATUS_CHARGING;
+               break;
+       case 0x02: /* charge complete */
+               status = POWER_SUPPLY_STATUS_FULL;
+               break;
+       /*
+        * 0x03 = charging error
+        */
+       default:
+               status = POWER_SUPPLY_STATUS_NOT_CHARGING;
+               break;
+       }
+
+       return status;
+}
+
+static int hidpp10_query_battery_mileage(struct hidpp_device *hidpp)
+{
+       struct hidpp_report response;
+       int ret, status;
+
+       ret = hidpp_send_rap_command_sync(hidpp,
+                                       REPORT_ID_HIDPP_SHORT,
+                                       HIDPP_GET_REGISTER,
+                                       HIDPP_REG_BATTERY_MILEAGE,
+                                       NULL, 0, &response);
+       if (ret)
+               return ret;
+
+       hidpp->battery.capacity = response.rap.params[0];
+       status = hidpp10_battery_mileage_map_status(response.rap.params[2]);
+       hidpp->battery.status = status;
+       /* the capacity is only available when discharging or full */
+       hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING ||
+                               status == POWER_SUPPLY_STATUS_FULL;
+
+       return 0;
+}
+
+static int hidpp10_battery_event(struct hidpp_device *hidpp, u8 *data, int size)
+{
+       struct hidpp_report *report = (struct hidpp_report *)data;
+       int status, capacity, level;
+       bool changed;
+
+       if (report->report_id != REPORT_ID_HIDPP_SHORT)
+               return 0;
+
+       switch (report->rap.sub_id) {
+       case HIDPP_REG_BATTERY_STATUS:
+               capacity = hidpp->battery.capacity;
+               level = hidpp10_battery_status_map_level(report->rawbytes[1]);
+               status = hidpp10_battery_status_map_status(report->rawbytes[2]);
+               break;
+       case HIDPP_REG_BATTERY_MILEAGE:
+               capacity = report->rap.params[0];
+               level = hidpp->battery.level;
+               status = hidpp10_battery_mileage_map_status(report->rawbytes[3]);
+               break;
+       default:
+               return 0;
+       }
+
+       changed = capacity != hidpp->battery.capacity ||
+                 level != hidpp->battery.level ||
+                 status != hidpp->battery.status;
+
+       /* the capacity is only available when discharging or full */
+       hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING ||
+                               status == POWER_SUPPLY_STATUS_FULL;
+
+       if (changed) {
+               hidpp->battery.level = level;
+               hidpp->battery.status = status;
+               if (hidpp->battery.ps)
+                       power_supply_changed(hidpp->battery.ps);
+       }
+
+       return 0;
+}
+
 #define HIDPP_REG_PAIRING_INFORMATION                  0xB5
-#define DEVICE_NAME                                    0x40
+#define HIDPP_EXTENDED_PAIRING                         0x30
+#define HIDPP_DEVICE_NAME                              0x40
 
-static char *hidpp_get_unifying_name(struct hidpp_device *hidpp_dev)
+static char *hidpp_unifying_get_name(struct hidpp_device *hidpp_dev)
 {
        struct hidpp_report response;
        int ret;
-       /* hid-logitech-dj is in charge of setting the right device index */
-       u8 params[1] = { DEVICE_NAME };
+       u8 params[1] = { HIDPP_DEVICE_NAME };
        char *name;
        int len;
 
@@ -417,6 +642,54 @@ static char *hidpp_get_unifying_name(struct hidpp_device *hidpp_dev)
        return name;
 }
 
+static int hidpp_unifying_get_serial(struct hidpp_device *hidpp, u32 *serial)
+{
+       struct hidpp_report response;
+       int ret;
+       u8 params[1] = { HIDPP_EXTENDED_PAIRING };
+
+       ret = hidpp_send_rap_command_sync(hidpp,
+                                       REPORT_ID_HIDPP_SHORT,
+                                       HIDPP_GET_LONG_REGISTER,
+                                       HIDPP_REG_PAIRING_INFORMATION,
+                                       params, 1, &response);
+       if (ret)
+               return ret;
+
+       /*
+        * We don't care about LE or BE, we will output it as a string
+        * with %4phD, so we need to keep the order.
+        */
+       *serial = *((u32 *)&response.rap.params[1]);
+       return 0;
+}
+
+static int hidpp_unifying_init(struct hidpp_device *hidpp)
+{
+       struct hid_device *hdev = hidpp->hid_dev;
+       const char *name;
+       u32 serial;
+       int ret;
+
+       ret = hidpp_unifying_get_serial(hidpp, &serial);
+       if (ret)
+               return ret;
+
+       snprintf(hdev->uniq, sizeof(hdev->uniq), "%04x-%4phD",
+                hdev->product, &serial);
+       dbg_hid("HID++ Unifying: Got serial: %s\n", hdev->uniq);
+
+       name = hidpp_unifying_get_name(hidpp);
+       if (!name)
+               return -EIO;
+
+       snprintf(hdev->name, sizeof(hdev->name), "%s", name);
+       dbg_hid("HID++ Unifying: Got name: %s\n", name);
+
+       kfree(name);
+       return 0;
+}
+
 /* -------------------------------------------------------------------------- */
 /* 0x0000: Root                                                               */
 /* -------------------------------------------------------------------------- */
@@ -441,6 +714,9 @@ static int hidpp_root_get_feature(struct hidpp_device *hidpp, u16 feature,
        if (ret)
                return ret;
 
+       if (response.fap.params[0] == 0)
+               return -ENOENT;
+
        *feature_index = response.fap.params[0];
        *feature_type = response.fap.params[1];
 
@@ -606,6 +882,355 @@ static char *hidpp_get_device_name(struct hidpp_device *hidpp)
        return name;
 }
 
+/* -------------------------------------------------------------------------- */
+/* 0x1000: Battery level status                                               */
+/* -------------------------------------------------------------------------- */
+
+#define HIDPP_PAGE_BATTERY_LEVEL_STATUS                                0x1000
+
+#define CMD_BATTERY_LEVEL_STATUS_GET_BATTERY_LEVEL_STATUS      0x00
+#define CMD_BATTERY_LEVEL_STATUS_GET_BATTERY_CAPABILITY                0x10
+
+#define EVENT_BATTERY_LEVEL_STATUS_BROADCAST                   0x00
+
+#define FLAG_BATTERY_LEVEL_DISABLE_OSD                         BIT(0)
+#define FLAG_BATTERY_LEVEL_MILEAGE                             BIT(1)
+#define FLAG_BATTERY_LEVEL_RECHARGEABLE                                BIT(2)
+
+static int hidpp_map_battery_level(int capacity)
+{
+       if (capacity < 11)
+               return POWER_SUPPLY_CAPACITY_LEVEL_CRITICAL;
+       else if (capacity < 31)
+               return POWER_SUPPLY_CAPACITY_LEVEL_LOW;
+       else if (capacity < 81)
+               return POWER_SUPPLY_CAPACITY_LEVEL_NORMAL;
+       return POWER_SUPPLY_CAPACITY_LEVEL_FULL;
+}
+
+static int hidpp20_batterylevel_map_status_capacity(u8 data[3], int *capacity,
+                                                   int *next_capacity,
+                                                   int *level)
+{
+       int status;
+
+       *capacity = data[0];
+       *next_capacity = data[1];
+       *level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN;
+
+       /* When discharging, we can rely on the device reported capacity.
+        * For all other states the device reports 0 (unknown).
+        */
+       switch (data[2]) {
+               case 0: /* discharging (in use) */
+                       status = POWER_SUPPLY_STATUS_DISCHARGING;
+                       *level = hidpp_map_battery_level(*capacity);
+                       break;
+               case 1: /* recharging */
+                       status = POWER_SUPPLY_STATUS_CHARGING;
+                       break;
+               case 2: /* charge in final stage */
+                       status = POWER_SUPPLY_STATUS_CHARGING;
+                       break;
+               case 3: /* charge complete */
+                       status = POWER_SUPPLY_STATUS_FULL;
+                       *level = POWER_SUPPLY_CAPACITY_LEVEL_FULL;
+                       *capacity = 100;
+                       break;
+               case 4: /* recharging below optimal speed */
+                       status = POWER_SUPPLY_STATUS_CHARGING;
+                       break;
+               /* 5 = invalid battery type
+                  6 = thermal error
+                  7 = other charging error */
+               default:
+                       status = POWER_SUPPLY_STATUS_NOT_CHARGING;
+                       break;
+       }
+
+       return status;
+}
+
+static int hidpp20_batterylevel_get_battery_capacity(struct hidpp_device *hidpp,
+                                                    u8 feature_index,
+                                                    int *status,
+                                                    int *capacity,
+                                                    int *next_capacity,
+                                                    int *level)
+{
+       struct hidpp_report response;
+       int ret;
+       u8 *params = (u8 *)response.fap.params;
+
+       ret = hidpp_send_fap_command_sync(hidpp, feature_index,
+                                         CMD_BATTERY_LEVEL_STATUS_GET_BATTERY_LEVEL_STATUS,
+                                         NULL, 0, &response);
+       if (ret > 0) {
+               hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
+                       __func__, ret);
+               return -EPROTO;
+       }
+       if (ret)
+               return ret;
+
+       *status = hidpp20_batterylevel_map_status_capacity(params, capacity,
+                                                          next_capacity,
+                                                          level);
+
+       return 0;
+}
+
+static int hidpp20_batterylevel_get_battery_info(struct hidpp_device *hidpp,
+                                                 u8 feature_index)
+{
+       struct hidpp_report response;
+       int ret;
+       u8 *params = (u8 *)response.fap.params;
+       unsigned int level_count, flags;
+
+       ret = hidpp_send_fap_command_sync(hidpp, feature_index,
+                                         CMD_BATTERY_LEVEL_STATUS_GET_BATTERY_CAPABILITY,
+                                         NULL, 0, &response);
+       if (ret > 0) {
+               hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
+                       __func__, ret);
+               return -EPROTO;
+       }
+       if (ret)
+               return ret;
+
+       level_count = params[0];
+       flags = params[1];
+
+       if (level_count < 10 || !(flags & FLAG_BATTERY_LEVEL_MILEAGE))
+               hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS;
+       else
+               hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE;
+
+       return 0;
+}
+
+static int hidpp20_query_battery_info(struct hidpp_device *hidpp)
+{
+       u8 feature_type;
+       int ret;
+       int status, capacity, next_capacity, level;
+
+       if (hidpp->battery.feature_index == 0xff) {
+               ret = hidpp_root_get_feature(hidpp,
+                                            HIDPP_PAGE_BATTERY_LEVEL_STATUS,
+                                            &hidpp->battery.feature_index,
+                                            &feature_type);
+               if (ret)
+                       return ret;
+       }
+
+       ret = hidpp20_batterylevel_get_battery_capacity(hidpp,
+                                               hidpp->battery.feature_index,
+                                               &status, &capacity,
+                                               &next_capacity, &level);
+       if (ret)
+               return ret;
+
+       ret = hidpp20_batterylevel_get_battery_info(hidpp,
+                                               hidpp->battery.feature_index);
+       if (ret)
+               return ret;
+
+       hidpp->battery.status = status;
+       hidpp->battery.capacity = capacity;
+       hidpp->battery.level = level;
+       /* the capacity is only available when discharging or full */
+       hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING ||
+                               status == POWER_SUPPLY_STATUS_FULL;
+
+       return 0;
+}
+
+static int hidpp20_battery_event(struct hidpp_device *hidpp,
+                                u8 *data, int size)
+{
+       struct hidpp_report *report = (struct hidpp_report *)data;
+       int status, capacity, next_capacity, level;
+       bool changed;
+
+       if (report->fap.feature_index != hidpp->battery.feature_index ||
+           report->fap.funcindex_clientid != EVENT_BATTERY_LEVEL_STATUS_BROADCAST)
+               return 0;
+
+       status = hidpp20_batterylevel_map_status_capacity(report->fap.params,
+                                                         &capacity,
+                                                         &next_capacity,
+                                                         &level);
+
+       /* the capacity is only available when discharging or full */
+       hidpp->battery.online = status == POWER_SUPPLY_STATUS_DISCHARGING ||
+                               status == POWER_SUPPLY_STATUS_FULL;
+
+       changed = capacity != hidpp->battery.capacity ||
+                 level != hidpp->battery.level ||
+                 status != hidpp->battery.status;
+
+       if (changed) {
+               hidpp->battery.level = level;
+               hidpp->battery.capacity = capacity;
+               hidpp->battery.status = status;
+               if (hidpp->battery.ps)
+                       power_supply_changed(hidpp->battery.ps);
+       }
+
+       return 0;
+}
+
+static enum power_supply_property hidpp_battery_props[] = {
+       POWER_SUPPLY_PROP_ONLINE,
+       POWER_SUPPLY_PROP_STATUS,
+       POWER_SUPPLY_PROP_SCOPE,
+       POWER_SUPPLY_PROP_MODEL_NAME,
+       POWER_SUPPLY_PROP_MANUFACTURER,
+       POWER_SUPPLY_PROP_SERIAL_NUMBER,
+       0, /* placeholder for POWER_SUPPLY_PROP_CAPACITY, */
+       0, /* placeholder for POWER_SUPPLY_PROP_CAPACITY_LEVEL, */
+};
+
+static int hidpp_battery_get_property(struct power_supply *psy,
+                                     enum power_supply_property psp,
+                                     union power_supply_propval *val)
+{
+       struct hidpp_device *hidpp = power_supply_get_drvdata(psy);
+       int ret = 0;
+
+       switch(psp) {
+               case POWER_SUPPLY_PROP_STATUS:
+                       val->intval = hidpp->battery.status;
+                       break;
+               case POWER_SUPPLY_PROP_CAPACITY:
+                       val->intval = hidpp->battery.capacity;
+                       break;
+               case POWER_SUPPLY_PROP_CAPACITY_LEVEL:
+                       val->intval = hidpp->battery.level;
+                       break;
+               case POWER_SUPPLY_PROP_SCOPE:
+                       val->intval = POWER_SUPPLY_SCOPE_DEVICE;
+                       break;
+               case POWER_SUPPLY_PROP_ONLINE:
+                       val->intval = hidpp->battery.online;
+                       break;
+               case POWER_SUPPLY_PROP_MODEL_NAME:
+                       if (!strncmp(hidpp->name, "Logitech ", 9))
+                               val->strval = hidpp->name + 9;
+                       else
+                               val->strval = hidpp->name;
+                       break;
+               case POWER_SUPPLY_PROP_MANUFACTURER:
+                       val->strval = "Logitech";
+                       break;
+               case POWER_SUPPLY_PROP_SERIAL_NUMBER:
+                       val->strval = hidpp->hid_dev->uniq;
+                       break;
+               default:
+                       ret = -EINVAL;
+                       break;
+       }
+
+       return ret;
+}
+
+/* -------------------------------------------------------------------------- */
+/* 0x4301: Solar Keyboard                                                     */
+/* -------------------------------------------------------------------------- */
+
+#define HIDPP_PAGE_SOLAR_KEYBOARD                      0x4301
+
+#define CMD_SOLAR_SET_LIGHT_MEASURE                    0x00
+
+#define EVENT_SOLAR_BATTERY_BROADCAST                  0x00
+#define EVENT_SOLAR_BATTERY_LIGHT_MEASURE              0x10
+#define EVENT_SOLAR_CHECK_LIGHT_BUTTON                 0x20
+
+static int hidpp_solar_request_battery_event(struct hidpp_device *hidpp)
+{
+       struct hidpp_report response;
+       u8 params[2] = { 1, 1 };
+       u8 feature_type;
+       int ret;
+
+       if (hidpp->battery.feature_index == 0xff) {
+               ret = hidpp_root_get_feature(hidpp,
+                                            HIDPP_PAGE_SOLAR_KEYBOARD,
+                                            &hidpp->battery.solar_feature_index,
+                                            &feature_type);
+               if (ret)
+                       return ret;
+       }
+
+       ret = hidpp_send_fap_command_sync(hidpp,
+                                         hidpp->battery.solar_feature_index,
+                                         CMD_SOLAR_SET_LIGHT_MEASURE,
+                                         params, 2, &response);
+       if (ret > 0) {
+               hid_err(hidpp->hid_dev, "%s: received protocol error 0x%02x\n",
+                       __func__, ret);
+               return -EPROTO;
+       }
+       if (ret)
+               return ret;
+
+       hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE;
+
+       return 0;
+}
+
+static int hidpp_solar_battery_event(struct hidpp_device *hidpp,
+                                    u8 *data, int size)
+{
+       struct hidpp_report *report = (struct hidpp_report *)data;
+       int capacity, lux, status;
+       u8 function;
+
+       function = report->fap.funcindex_clientid;
+
+
+       if (report->fap.feature_index != hidpp->battery.solar_feature_index ||
+           !(function == EVENT_SOLAR_BATTERY_BROADCAST ||
+             function == EVENT_SOLAR_BATTERY_LIGHT_MEASURE ||
+             function == EVENT_SOLAR_CHECK_LIGHT_BUTTON))
+               return 0;
+
+       capacity = report->fap.params[0];
+
+       switch (function) {
+       case EVENT_SOLAR_BATTERY_LIGHT_MEASURE:
+               lux = (report->fap.params[1] << 8) | report->fap.params[2];
+               if (lux > 200)
+                       status = POWER_SUPPLY_STATUS_CHARGING;
+               else
+                       status = POWER_SUPPLY_STATUS_DISCHARGING;
+               break;
+       case EVENT_SOLAR_CHECK_LIGHT_BUTTON:
+       default:
+               if (capacity < hidpp->battery.capacity)
+                       status = POWER_SUPPLY_STATUS_DISCHARGING;
+               else
+                       status = POWER_SUPPLY_STATUS_CHARGING;
+
+       }
+
+       if (capacity == 100)
+               status = POWER_SUPPLY_STATUS_FULL;
+
+       hidpp->battery.online = true;
+       if (capacity != hidpp->battery.capacity ||
+           status != hidpp->battery.status) {
+               hidpp->battery.capacity = capacity;
+               hidpp->battery.status = status;
+               if (hidpp->battery.ps)
+                       power_supply_changed(hidpp->battery.ps);
+       }
+
+       return 0;
+}
+
 /* -------------------------------------------------------------------------- */
 /* 0x6010: Touchpad FW items                                                  */
 /* -------------------------------------------------------------------------- */
@@ -1599,9 +2224,6 @@ static int wtp_connect(struct hid_device *hdev, bool connected)
        struct wtp_data *wd = hidpp->private_data;
        int ret;
 
-       if (!connected)
-               return 0;
-
        if (!wd->x_size) {
                ret = wtp_get_config(hidpp);
                if (ret) {
@@ -1669,9 +2291,6 @@ static int m560_send_config_command(struct hid_device *hdev, bool connected)
 
        hidpp_dev = hid_get_drvdata(hdev);
 
-       if (!connected)
-               return -ENODEV;
-
        return hidpp_send_rap_command_sync(
                hidpp_dev,
                REPORT_ID_HIDPP_SHORT,
@@ -1875,9 +2494,6 @@ static int k400_connect(struct hid_device *hdev, bool connected)
 {
        struct hidpp_device *hidpp = hid_get_drvdata(hdev);
 
-       if (!connected)
-               return 0;
-
        if (!disable_tap_to_click)
                return 0;
 
@@ -1974,6 +2590,7 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
        struct hidpp_report *question = hidpp->send_receive_buf;
        struct hidpp_report *answer = hidpp->send_receive_buf;
        struct hidpp_report *report = (struct hidpp_report *)data;
+       int ret;
 
        /*
         * If the mutex is locked then we have a pending answer from a
@@ -2002,12 +2619,26 @@ static int hidpp_raw_hidpp_event(struct hidpp_device *hidpp, u8 *data,
        if (unlikely(hidpp_report_is_connect_event(report))) {
                atomic_set(&hidpp->connected,
                                !(report->rap.params[0] & (1 << 6)));
-               if ((hidpp->quirks & HIDPP_QUIRK_CONNECT_EVENTS) &&
-                   (schedule_work(&hidpp->work) == 0))
+               if (schedule_work(&hidpp->work) == 0)
                        dbg_hid("%s: connect event already queued\n", __func__);
                return 1;
        }
 
+       if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) {
+               ret = hidpp20_battery_event(hidpp, data, size);
+               if (ret != 0)
+                       return ret;
+               ret = hidpp_solar_battery_event(hidpp, data, size);
+               if (ret != 0)
+                       return ret;
+       }
+
+       if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) {
+               ret = hidpp10_battery_event(hidpp, data, size);
+               if (ret != 0)
+                       return ret;
+       }
+
        return 0;
 }
 
@@ -2058,20 +2689,90 @@ static int hidpp_raw_event(struct hid_device *hdev, struct hid_report *report,
        return 0;
 }
 
-static void hidpp_overwrite_name(struct hid_device *hdev, bool use_unifying)
+static int hidpp_initialize_battery(struct hidpp_device *hidpp)
+{
+       static atomic_t battery_no = ATOMIC_INIT(0);
+       struct power_supply_config cfg = { .drv_data = hidpp };
+       struct power_supply_desc *desc = &hidpp->battery.desc;
+       enum power_supply_property *battery_props;
+       struct hidpp_battery *battery;
+       unsigned int num_battery_props;
+       unsigned long n;
+       int ret;
+
+       if (hidpp->battery.ps)
+               return 0;
+
+       hidpp->battery.feature_index = 0xff;
+       hidpp->battery.solar_feature_index = 0xff;
+
+       if (hidpp->protocol_major >= 2) {
+               if (hidpp->quirks & HIDPP_QUIRK_CLASS_K750)
+                       ret = hidpp_solar_request_battery_event(hidpp);
+               else
+                       ret = hidpp20_query_battery_info(hidpp);
+
+               if (ret)
+                       return ret;
+               hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP20_BATTERY;
+       } else {
+               ret = hidpp10_query_battery_status(hidpp);
+               if (ret) {
+                       ret = hidpp10_query_battery_mileage(hidpp);
+                       if (ret)
+                               return -ENOENT;
+                       hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_MILEAGE;
+               } else {
+                       hidpp->capabilities |= HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS;
+               }
+               hidpp->capabilities |= HIDPP_CAPABILITY_HIDPP10_BATTERY;
+       }
+
+       battery_props = devm_kmemdup(&hidpp->hid_dev->dev,
+                                    hidpp_battery_props,
+                                    sizeof(hidpp_battery_props),
+                                    GFP_KERNEL);
+       num_battery_props = ARRAY_SIZE(hidpp_battery_props) - 2;
+
+       if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE)
+               battery_props[num_battery_props++] =
+                               POWER_SUPPLY_PROP_CAPACITY;
+
+       if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_LEVEL_STATUS)
+               battery_props[num_battery_props++] =
+                               POWER_SUPPLY_PROP_CAPACITY_LEVEL;
+
+       battery = &hidpp->battery;
+
+       n = atomic_inc_return(&battery_no) - 1;
+       desc->properties = battery_props;
+       desc->num_properties = num_battery_props;
+       desc->get_property = hidpp_battery_get_property;
+       sprintf(battery->name, "hidpp_battery_%ld", n);
+       desc->name = battery->name;
+       desc->type = POWER_SUPPLY_TYPE_BATTERY;
+       desc->use_for_apm = 0;
+
+       battery->ps = devm_power_supply_register(&hidpp->hid_dev->dev,
+                                                &battery->desc,
+                                                &cfg);
+       if (IS_ERR(battery->ps))
+               return PTR_ERR(battery->ps);
+
+       power_supply_powers(battery->ps, &hidpp->hid_dev->dev);
+
+       return ret;
+}
+
+static void hidpp_overwrite_name(struct hid_device *hdev)
 {
        struct hidpp_device *hidpp = hid_get_drvdata(hdev);
        char *name;
 
-       if (use_unifying)
-               /*
-                * the device is connected through an Unifying receiver, and
-                * might not be already connected.
-                * Ask the receiver for its name.
-                */
-               name = hidpp_get_unifying_name(hidpp);
-       else
-               name = hidpp_get_device_name(hidpp);
+       if (hidpp->protocol_major < 2)
+               return;
+
+       name = hidpp_get_device_name(hidpp);
 
        if (!name) {
                hid_err(hdev, "unable to retrieve the name of the device");
@@ -2129,6 +2830,16 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
        struct input_dev *input;
        char *name, *devm_name;
 
+       if (!connected) {
+               if (hidpp->battery.ps) {
+                       hidpp->battery.online = false;
+                       hidpp->battery.status = POWER_SUPPLY_STATUS_UNKNOWN;
+                       hidpp->battery.level = POWER_SUPPLY_CAPACITY_LEVEL_UNKNOWN;
+                       power_supply_changed(hidpp->battery.ps);
+               }
+               return;
+       }
+
        if (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP) {
                ret = wtp_connect(hdev, connected);
                if (ret)
@@ -2143,9 +2854,6 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
                        return;
        }
 
-       if (!connected || hidpp->delayed_input)
-               return;
-
        /* the device is already connected, we can ask for its name and
         * protocol */
        if (!hidpp->protocol_major) {
@@ -2158,11 +2866,7 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
                         hidpp->protocol_major, hidpp->protocol_minor);
        }
 
-       if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT))
-               /* if HID created the input nodes for us, we can stop now */
-               return;
-
-       if (!hidpp->name || hidpp->name == hdev->name) {
+       if (hidpp->name == hdev->name && hidpp->protocol_major >= 2) {
                name = hidpp_get_device_name(hidpp);
                if (!name) {
                        hid_err(hdev,
@@ -2178,6 +2882,25 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
                hidpp->name = devm_name;
        }
 
+       hidpp_initialize_battery(hidpp);
+
+       /* forward current battery state */
+       if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP10_BATTERY) {
+               hidpp10_enable_battery_reporting(hidpp);
+               if (hidpp->capabilities & HIDPP_CAPABILITY_BATTERY_MILEAGE)
+                       hidpp10_query_battery_mileage(hidpp);
+               else
+                       hidpp10_query_battery_status(hidpp);
+       } else if (hidpp->capabilities & HIDPP_CAPABILITY_HIDPP20_BATTERY) {
+               hidpp20_query_battery_info(hidpp);
+       }
+       if (hidpp->battery.ps)
+               power_supply_changed(hidpp->battery.ps);
+
+       if (!(hidpp->quirks & HIDPP_QUIRK_NO_HIDINPUT) || hidpp->delayed_input)
+               /* if the input nodes are already created, we can stop now */
+               return;
+
        input = hidpp_allocate_input(hdev);
        if (!input) {
                hid_err(hdev, "cannot allocate new input device: %d\n", ret);
@@ -2193,6 +2916,17 @@ static void hidpp_connect_event(struct hidpp_device *hidpp)
        hidpp->delayed_input = input;
 }
 
+static DEVICE_ATTR(builtin_power_supply, 0000, NULL, NULL);
+
+static struct attribute *sysfs_attrs[] = {
+       &dev_attr_builtin_power_supply.attr,
+       NULL
+};
+
+static struct attribute_group ps_attribute_group = {
+       .attrs = sysfs_attrs
+};
+
 static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 {
        struct hidpp_device *hidpp;
@@ -2211,9 +2945,11 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
        hidpp->quirks = id->driver_data;
 
+       if (id->group == HID_GROUP_LOGITECH_DJ_DEVICE)
+               hidpp->quirks |= HIDPP_QUIRK_UNIFYING;
+
        if (disable_raw_mode) {
                hidpp->quirks &= ~HIDPP_QUIRK_CLASS_WTP;
-               hidpp->quirks &= ~HIDPP_QUIRK_CONNECT_EVENTS;
                hidpp->quirks &= ~HIDPP_QUIRK_NO_HIDINPUT;
        }
 
@@ -2235,6 +2971,12 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
        mutex_init(&hidpp->send_mutex);
        init_waitqueue_head(&hidpp->wait);
 
+       /* indicates we are handling the battery properties in the kernel */
+       ret = sysfs_create_group(&hdev->dev.kobj, &ps_attribute_group);
+       if (ret)
+               hid_warn(hdev, "Cannot allocate sysfs group for %s\n",
+                        hdev->name);
+
        ret = hid_parse(hdev);
        if (ret) {
                hid_err(hdev, "%s:parse failed\n", __func__);
@@ -2263,8 +3005,12 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
        /* Allow incoming packets */
        hid_device_io_start(hdev);
 
+       if (hidpp->quirks & HIDPP_QUIRK_UNIFYING)
+               hidpp_unifying_init(hidpp);
+
        connected = hidpp_is_connected(hidpp);
-       if (id->group != HID_GROUP_LOGITECH_DJ_DEVICE) {
+       atomic_set(&hidpp->connected, connected);
+       if (!(hidpp->quirks & HIDPP_QUIRK_UNIFYING)) {
                if (!connected) {
                        ret = -ENODEV;
                        hid_err(hdev, "Device not connected");
@@ -2273,10 +3019,9 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
 
                hid_info(hdev, "HID++ %u.%u device connected.\n",
                         hidpp->protocol_major, hidpp->protocol_minor);
-       }
 
-       hidpp_overwrite_name(hdev, id->group == HID_GROUP_LOGITECH_DJ_DEVICE);
-       atomic_set(&hidpp->connected, connected);
+               hidpp_overwrite_name(hdev);
+       }
 
        if (connected && (hidpp->quirks & HIDPP_QUIRK_CLASS_WTP)) {
                ret = wtp_get_config(hidpp);
@@ -2299,12 +3044,10 @@ static int hidpp_probe(struct hid_device *hdev, const struct hid_device_id *id)
                }
        }
 
-       if (hidpp->quirks & HIDPP_QUIRK_CONNECT_EVENTS) {
-               /* Allow incoming packets */
-               hid_device_io_start(hdev);
+       /* Allow incoming packets */
+       hid_device_io_start(hdev);
 
-               hidpp_connect_event(hidpp);
-       }
+       hidpp_connect_event(hidpp);
 
        return ret;
 
@@ -2316,6 +3059,7 @@ hid_hw_open_failed:
        }
 hid_hw_start_fail:
 hid_parse_fail:
+       sysfs_remove_group(&hdev->dev.kobj, &ps_attribute_group);
        cancel_work_sync(&hidpp->work);
        mutex_destroy(&hidpp->send_mutex);
 allocate_fail:
@@ -2327,6 +3071,8 @@ static void hidpp_remove(struct hid_device *hdev)
 {
        struct hidpp_device *hidpp = hid_get_drvdata(hdev);
 
+       sysfs_remove_group(&hdev->dev.kobj, &ps_attribute_group);
+
        if (hidpp->quirks & HIDPP_QUIRK_CLASS_G920) {
                hidpp_ff_deinit(hdev);
                hid_hw_close(hdev);
@@ -2357,7 +3103,11 @@ static const struct hid_device_id hidpp_devices[] = {
        { /* Keyboard logitech K400 */
          HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
                USB_VENDOR_ID_LOGITECH, 0x4024),
-         .driver_data = HIDPP_QUIRK_CONNECT_EVENTS | HIDPP_QUIRK_CLASS_K400 },
+         .driver_data = HIDPP_QUIRK_CLASS_K400 },
+       { /* Solar Keyboard Logitech K750 */
+         HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
+               USB_VENDOR_ID_LOGITECH, 0x4002),
+         .driver_data = HIDPP_QUIRK_CLASS_K750 },
 
        { HID_DEVICE(BUS_USB, HID_GROUP_LOGITECH_DJ_DEVICE,
                USB_VENDOR_ID_LOGITECH, HID_ANY_ID)},
index 692647485a53b3316ec442518b0b84648113dda9..24d5b6deb5718356f52c3953a3fe5aa068d7563c 100644 (file)
@@ -69,6 +69,7 @@ MODULE_LICENSE("GPL");
 #define MT_QUIRK_CONTACT_CNT_ACCURATE  (1 << 12)
 #define MT_QUIRK_FORCE_GET_FEATURE     (1 << 13)
 #define MT_QUIRK_FIX_CONST_CONTACT_ID  (1 << 14)
+#define MT_QUIRK_TOUCH_SIZE_SCALING    (1 << 15)
 
 #define MT_INPUTMODE_TOUCHSCREEN       0x02
 #define MT_INPUTMODE_TOUCHPAD          0x03
@@ -222,7 +223,8 @@ static struct mt_class mt_classes[] = {
         */
        { .name = MT_CLS_3M,
                .quirks = MT_QUIRK_VALID_IS_CONFIDENCE |
-                       MT_QUIRK_SLOT_IS_CONTACTID,
+                       MT_QUIRK_SLOT_IS_CONTACTID |
+                       MT_QUIRK_TOUCH_SIZE_SCALING,
                .sn_move = 2048,
                .sn_width = 128,
                .sn_height = 128,
@@ -658,9 +660,17 @@ static void mt_complete_slot(struct mt_device *td, struct input_dev *input)
                if (active) {
                        /* this finger is in proximity of the sensor */
                        int wide = (s->w > s->h);
-                       /* divided by two to match visual scale of touch */
-                       int major = max(s->w, s->h) >> 1;
-                       int minor = min(s->w, s->h) >> 1;
+                       int major = max(s->w, s->h);
+                       int minor = min(s->w, s->h);
+
+                       /*
+                        * divided by two to match visual scale of touch
+                        * for devices with this quirk
+                        */
+                       if (td->mtclass.quirks & MT_QUIRK_TOUCH_SIZE_SCALING) {
+                               major = major >> 1;
+                               minor = minor >> 1;
+                       }
 
                        input_event(input, EV_ABS, ABS_MT_POSITION_X, s->x);
                        input_event(input, EV_ABS, ABS_MT_POSITION_Y, s->y);
diff --git a/drivers/hid/hid-nti.c b/drivers/hid/hid-nti.c
new file mode 100644 (file)
index 0000000..5bb827b
--- /dev/null
@@ -0,0 +1,59 @@
+/*
+ *  USB HID quirks support for Network Technologies, Inc. "USB-SUN" USB
+ *  adapter for pre-USB Sun keyboards
+ *
+ *  Copyright (c) 2011 Google, Inc.
+ *
+ * Based on HID apple driver by
+ *  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) 2006-2007 Jiri Kosina
+ *  Copyright (c) 2008 Jiri Slaby <jirislaby@gmail.com>
+ */
+
+/*
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the Free
+ * Software Foundation; either version 2 of the License, or (at your option)
+ * any later version.
+ */
+
+#include <linux/device.h>
+#include <linux/input.h>
+#include <linux/hid.h>
+#include <linux/module.h>
+
+#include "hid-ids.h"
+
+MODULE_AUTHOR("Jonathan Klabunde Tomer <jktomer@google.com>");
+MODULE_DESCRIPTION("HID driver for Network Technologies USB-SUN keyboard adapter");
+
+/*
+ * NTI Sun keyboard adapter has wrong logical maximum in report descriptor
+ */
+static __u8 *nti_usbsun_report_fixup(struct hid_device *hdev, __u8 *rdesc,
+               unsigned int *rsize)
+{
+       if (*rsize >= 60 && rdesc[53] == 0x65 && rdesc[59] == 0x65) {
+               hid_info(hdev, "fixing up NTI USB-SUN keyboard adapter report descriptor\n");
+               rdesc[53] = rdesc[59] = 0xe7;
+       }
+       return rdesc;
+}
+
+static const struct hid_device_id nti_devices[] = {
+       { HID_USB_DEVICE(USB_VENDOR_ID_NTI, USB_DEVICE_ID_USB_SUN) },
+       { }
+};
+MODULE_DEVICE_TABLE(hid, nti_devices);
+
+static struct hid_driver nti_driver = {
+       .name = "nti",
+       .id_table = nti_devices,
+       .report_fixup = nti_usbsun_report_fixup
+};
+
+module_hid_driver(nti_driver);
+
+MODULE_LICENSE("GPL");
index f405b07d03816506215bd19fe3c878393370484a..740996f9bdd49dde3d26659f68d2addbff291c60 100644 (file)
@@ -2632,6 +2632,8 @@ err_stop:
                sony_leds_remove(sc);
        if (sc->quirks & SONY_BATTERY_SUPPORT)
                sony_battery_remove(sc);
+       if (sc->touchpad)
+               sony_unregister_touchpad(sc);
        sony_cancel_work_sync(sc);
        kfree(sc->output_report_dmabuf);
        sony_remove_dev_list(sc);
index 1509d7287ff3e60e79c845214e47e901fae650f8..e3e6e5c893cc05e0c934c8c9f505de9fdd06e26a 100644 (file)
@@ -977,6 +977,7 @@ static int uclogic_probe(struct hid_device *hdev,
                }
                break;
        case USB_DEVICE_ID_UGTIZER_TABLET_GP0610:
+       case USB_DEVICE_ID_UGEE_TABLET_EX07S:
                /* If this is the pen interface */
                if (intf->cur_altsetting->desc.bInterfaceNumber == 1) {
                        rc = uclogic_tablet_enable(hdev);
@@ -1069,6 +1070,7 @@ static const struct hid_device_id uclogic_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UGEE_TABLET_45) },
        { HID_USB_DEVICE(USB_VENDOR_ID_UCLOGIC, USB_DEVICE_ID_UCLOGIC_DRAWIMAGE_G3) },
        { HID_USB_DEVICE(USB_VENDOR_ID_UGTIZER, USB_DEVICE_ID_UGTIZER_TABLET_GP0610) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_UGEE, USB_DEVICE_ID_UGEE_TABLET_EX07S) },
        { }
 };
 MODULE_DEVICE_TABLE(hid, uclogic_devices);
index 7df5227a7e61d6ff79acd62cb009e29ffa4b79d8..9ad7731d2e10dad45268b55fbcf9dfc025570682 100644 (file)
@@ -46,6 +46,7 @@ static int xinmo_event(struct hid_device *hdev, struct hid_field *field,
 
 static const struct hid_device_id xinmo_devices[] = {
        { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_XIN_MO_DUAL_ARCADE) },
+       { HID_USB_DEVICE(USB_VENDOR_ID_XIN_MO, USB_DEVICE_ID_THT_2P_ARCADE) },
        { }
 };
 
index ea3c3546cef7f81f0f1c82b996c3ed5ab9fb26ed..8daa8ce64ebba51e91e57ec801fa7e702fb2a072 100644 (file)
@@ -508,66 +508,6 @@ static int i2c_hid_get_report_length(struct hid_report *report)
                report->device->report_enum[report->type].numbered + 2;
 }
 
-static void i2c_hid_init_report(struct hid_report *report, u8 *buffer,
-       size_t bufsize)
-{
-       struct hid_device *hid = report->device;
-       struct i2c_client *client = hid->driver_data;
-       struct i2c_hid *ihid = i2c_get_clientdata(client);
-       unsigned int size, ret_size;
-
-       size = i2c_hid_get_report_length(report);
-       if (i2c_hid_get_report(client,
-                       report->type == HID_FEATURE_REPORT ? 0x03 : 0x01,
-                       report->id, buffer, size))
-               return;
-
-       i2c_hid_dbg(ihid, "report (len=%d): %*ph\n", size, size, buffer);
-
-       ret_size = buffer[0] | (buffer[1] << 8);
-
-       if (ret_size != size) {
-               dev_err(&client->dev, "error in %s size:%d / ret_size:%d\n",
-                       __func__, size, ret_size);
-               return;
-       }
-
-       /* hid->driver_lock is held as we are in probe function,
-        * we just need to setup the input fields, so using
-        * hid_report_raw_event is safe. */
-       hid_report_raw_event(hid, report->type, buffer + 2, size - 2, 1);
-}
-
-/*
- * Initialize all reports
- */
-static void i2c_hid_init_reports(struct hid_device *hid)
-{
-       struct hid_report *report;
-       struct i2c_client *client = hid->driver_data;
-       struct i2c_hid *ihid = i2c_get_clientdata(client);
-       u8 *inbuf = kzalloc(ihid->bufsize, GFP_KERNEL);
-
-       if (!inbuf) {
-               dev_err(&client->dev, "can not retrieve initial reports\n");
-               return;
-       }
-
-       /*
-        * The device must be powered on while we fetch initial reports
-        * from it.
-        */
-       pm_runtime_get_sync(&client->dev);
-
-       list_for_each_entry(report,
-               &hid->report_enum[HID_FEATURE_REPORT].report_list, list)
-               i2c_hid_init_report(report, inbuf, ihid->bufsize);
-
-       pm_runtime_put(&client->dev);
-
-       kfree(inbuf);
-}
-
 /*
  * Traverse the supplied list of reports and find the longest
  */
@@ -789,9 +729,6 @@ static int i2c_hid_start(struct hid_device *hid)
                        return ret;
        }
 
-       if (!(hid->quirks & HID_QUIRK_NO_INIT_REPORTS))
-               i2c_hid_init_reports(hid);
-
        return 0;
 }
 
@@ -994,6 +931,11 @@ static int i2c_hid_of_probe(struct i2c_client *client,
        }
        pdata->hid_descriptor_address = val;
 
+       ret = of_property_read_u32(dev->of_node, "post-power-on-delay-ms",
+                                  &val);
+       if (!ret)
+               pdata->post_power_delay_ms = val;
+
        return 0;
 }
 
@@ -1053,6 +995,24 @@ static int i2c_hid_probe(struct i2c_client *client,
                ihid->pdata = *platform_data;
        }
 
+       ihid->pdata.supply = devm_regulator_get(&client->dev, "vdd");
+       if (IS_ERR(ihid->pdata.supply)) {
+               ret = PTR_ERR(ihid->pdata.supply);
+               if (ret != -EPROBE_DEFER)
+                       dev_err(&client->dev, "Failed to get regulator: %d\n",
+                               ret);
+               goto err;
+       }
+
+       ret = regulator_enable(ihid->pdata.supply);
+       if (ret < 0) {
+               dev_err(&client->dev, "Failed to enable regulator: %d\n",
+                       ret);
+               goto err;
+       }
+       if (ihid->pdata.post_power_delay_ms)
+               msleep(ihid->pdata.post_power_delay_ms);
+
        i2c_set_clientdata(client, ihid);
 
        ihid->client = client;
@@ -1068,7 +1028,7 @@ static int i2c_hid_probe(struct i2c_client *client,
         * real computation later. */
        ret = i2c_hid_alloc_buffers(ihid, HID_MIN_BUFFER_SIZE);
        if (ret < 0)
-               goto err;
+               goto err_regulator;
 
        pm_runtime_get_noresume(&client->dev);
        pm_runtime_set_active(&client->dev);
@@ -1125,6 +1085,9 @@ err_pm:
        pm_runtime_put_noidle(&client->dev);
        pm_runtime_disable(&client->dev);
 
+err_regulator:
+       regulator_disable(ihid->pdata.supply);
+
 err:
        i2c_hid_free_buffers(ihid);
        kfree(ihid);
@@ -1149,6 +1112,8 @@ static int i2c_hid_remove(struct i2c_client *client)
        if (ihid->bufsize)
                i2c_hid_free_buffers(ihid);
 
+       regulator_disable(ihid->pdata.supply);
+
        kfree(ihid);
 
        return 0;
@@ -1199,6 +1164,10 @@ static int i2c_hid_suspend(struct device *dev)
                else
                        hid_warn(hid, "Failed to enable irq wake: %d\n",
                                wake_status);
+       } else {
+               ret = regulator_disable(ihid->pdata.supply);
+               if (ret < 0)
+                       hid_warn(hid, "Failed to disable supply: %d\n", ret);
        }
 
        return 0;
@@ -1212,7 +1181,13 @@ static int i2c_hid_resume(struct device *dev)
        struct hid_device *hid = ihid->hid;
        int wake_status;
 
-       if (device_may_wakeup(&client->dev) && ihid->irq_wake_enabled) {
+       if (!device_may_wakeup(&client->dev)) {
+               ret = regulator_enable(ihid->pdata.supply);
+               if (ret < 0)
+                       hid_warn(hid, "Failed to enable supply: %d\n", ret);
+               if (ihid->pdata.post_power_delay_ms)
+                       msleep(ihid->pdata.post_power_delay_ms);
+       } else if (ihid->irq_wake_enabled) {
                wake_status = disable_irq_wake(client->irq);
                if (!wake_status)
                        ihid->irq_wake_enabled = false;
index 961bc6fdd2d908835fa9a07d169a4746fb44189d..83772fa7d92a6f6178cd3a4a5c0fea28350040b5 100644 (file)
@@ -52,6 +52,10 @@ static unsigned int hid_mousepoll_interval;
 module_param_named(mousepoll, hid_mousepoll_interval, uint, 0644);
 MODULE_PARM_DESC(mousepoll, "Polling interval of mice");
 
+static unsigned int hid_jspoll_interval;
+module_param_named(jspoll, hid_jspoll_interval, uint, 0644);
+MODULE_PARM_DESC(jspoll, "Polling interval of joysticks");
+
 static unsigned int ignoreled;
 module_param_named(ignoreled, ignoreled, uint, 0644);
 MODULE_PARM_DESC(ignoreled, "Autosuspend with active leds");
@@ -753,11 +757,9 @@ void usbhid_init_reports(struct hid_device *hid)
        struct hid_report_enum *report_enum;
        int err, ret;
 
-       if (!(hid->quirks & HID_QUIRK_NO_INIT_INPUT_REPORTS)) {
-               report_enum = &hid->report_enum[HID_INPUT_REPORT];
-               list_for_each_entry(report, &report_enum->report_list, list)
-                       usbhid_submit_report(hid, report, USB_DIR_IN);
-       }
+       report_enum = &hid->report_enum[HID_INPUT_REPORT];
+       list_for_each_entry(report, &report_enum->report_list, list)
+               usbhid_submit_report(hid, report, USB_DIR_IN);
 
        report_enum = &hid->report_enum[HID_FEATURE_REPORT];
        list_for_each_entry(report, &report_enum->report_list, list)
@@ -1004,10 +1006,9 @@ static int usbhid_parse(struct hid_device *hid)
                return -EINVAL;
        }
 
-       if (!(rdesc = kmalloc(rsize, GFP_KERNEL))) {
-               dbg_hid("couldn't allocate rdesc memory\n");
+       rdesc = kmalloc(rsize, GFP_KERNEL);
+       if (!rdesc)
                return -ENOMEM;
-       }
 
        hid_set_idle(dev, interface->desc.bInterfaceNumber, 0, 0);
 
@@ -1077,13 +1078,21 @@ static int usbhid_start(struct hid_device *hid)
                if (hid->quirks & HID_QUIRK_FULLSPEED_INTERVAL &&
                    dev->speed == USB_SPEED_HIGH) {
                        interval = fls(endpoint->bInterval*8);
-                       printk(KERN_INFO "%s: Fixing fullspeed to highspeed interval: %d -> %d\n",
-                              hid->name, endpoint->bInterval, interval);
+                       pr_info("%s: Fixing fullspeed to highspeed interval: %d -> %d\n",
+                               hid->name, endpoint->bInterval, interval);
                }
 
-               /* Change the polling interval of mice. */
-               if (hid->collection->usage == HID_GD_MOUSE && hid_mousepoll_interval > 0)
-                       interval = hid_mousepoll_interval;
+               /* Change the polling interval of mice and joysticks. */
+               switch (hid->collection->usage) {
+               case HID_GD_MOUSE:
+                       if (hid_mousepoll_interval > 0)
+                               interval = hid_mousepoll_interval;
+                       break;
+               case HID_GD_JOYSTICK:
+                       if (hid_jspoll_interval > 0)
+                               interval = hid_jspoll_interval;
+                       break;
+               }
 
                ret = -ENOMEM;
                if (usb_endpoint_dir_in(endpoint)) {
@@ -1120,9 +1129,6 @@ static int usbhid_start(struct hid_device *hid)
        usbhid->urbctrl->transfer_dma = usbhid->ctrlbuf_dma;
        usbhid->urbctrl->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
 
-       if (!(hid->quirks & HID_QUIRK_NO_INIT_REPORTS))
-               usbhid_init_reports(hid);
-
        set_bit(HID_STARTED, &usbhid->iofl);
 
        if (hid->quirks & HID_QUIRK_ALWAYS_POLL) {
@@ -1456,10 +1462,9 @@ static int hid_post_reset(struct usb_interface *intf)
         * the size of the HID report descriptor has not changed.
         */
        rdesc = kmalloc(hid->dev_rsize, GFP_KERNEL);
-       if (!rdesc) {
-               dbg_hid("couldn't allocate rdesc memory (post_reset)\n");
+       if (!rdesc)
                return -ENOMEM;
-       }
+
        status = hid_get_class_descriptor(dev,
                                interface->desc.bInterfaceNumber,
                                HID_DT_REPORT, rdesc, hid->dev_rsize);
@@ -1637,7 +1642,7 @@ static int __init hid_init(void)
        retval = usb_register(&hid_driver);
        if (retval)
                goto usb_register_fail;
-       printk(KERN_INFO KBUILD_MODNAME ": " DRIVER_DESC "\n");
+       pr_info(KBUILD_MODNAME ": " DRIVER_DESC "\n");
 
        return 0;
 usb_register_fail:
index d6847a664446529831395a962aacab7cb49ab8f5..6316498b78128574ff63b0047772f009e6d0cfeb 100644 (file)
@@ -65,6 +65,7 @@ static const struct hid_blacklist {
        { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_4PORTKVMC, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS682, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS692, HID_QUIRK_NOGET },
+       { USB_VENDOR_ID_ATEN, USB_DEVICE_ID_ATEN_CS1758, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FIGHTERSTICK, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_COMBATSTICK, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_CH, USB_DEVICE_ID_CH_FLIGHT_SIM_ECLIPSE_YOKE, HID_QUIRK_NOGET },
@@ -80,6 +81,9 @@ static const struct hid_blacklist {
        { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70RGB, HID_QUIRK_NO_INIT_REPORTS },
        { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB, HID_QUIRK_NO_INIT_REPORTS },
        { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_STRAFE, HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
+       { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K70RGB_RAPIDFIRE, HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
+       { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_K65RGB_RAPIDFIRE, HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
+       { USB_VENDOR_ID_CORSAIR, USB_DEVICE_ID_CORSAIR_SCIMITAR_PRO_RGB, HID_QUIRK_NO_INIT_REPORTS | HID_QUIRK_ALWAYS_POLL },
        { USB_VENDOR_ID_CREATIVELABS, USB_DEVICE_ID_CREATIVE_SB_OMNI_SURROUND_51, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_DMI, USB_DEVICE_ID_DMI_ENC, HID_QUIRK_NOGET },
        { USB_VENDOR_ID_DRAGONRISE, USB_DEVICE_ID_DRAGONRISE_WIIU, HID_QUIRK_MULTI_INPUT },
@@ -158,10 +162,11 @@ static const struct hid_blacklist {
        { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_HD, HID_QUIRK_NO_INIT_REPORTS },
        { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_QUAD_HD, HID_QUIRK_NO_INIT_REPORTS },
        { USB_VENDOR_ID_SYNAPTICS, USB_DEVICE_ID_SYNAPTICS_TP_V103, HID_QUIRK_NO_INIT_REPORTS },
-       { USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A096, HID_QUIRK_NO_INIT_INPUT_REPORTS },
+       { USB_VENDOR_ID_HOLTEK_ALT, USB_DEVICE_ID_HOLTEK_ALT_KEYBOARD_A096, HID_QUIRK_NO_INIT_REPORTS },
        { USB_VENDOR_ID_MULTIPLE_1781, USB_DEVICE_ID_RAPHNET_4NES4SNES_OLD, HID_QUIRK_MULTI_INPUT },
        { USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_2NES2SNES, HID_QUIRK_MULTI_INPUT },
        { USB_VENDOR_ID_DRACAL_RAPHNET, USB_DEVICE_ID_RAPHNET_4NES4SNES, HID_QUIRK_MULTI_INPUT },
+       { USB_VENDOR_ID_INNOMEDIA, USB_DEVICE_ID_INNEX_GENESIS_ATARI, HID_QUIRK_MULTI_INPUT },
 
        { 0, 0 }
 };
@@ -237,10 +242,8 @@ static int usbhid_modify_dquirk(const u16 idVendor, const u16 idProduct,
        }
 
        q_new = kmalloc(sizeof(struct quirks_list_struct), GFP_KERNEL);
-       if (!q_new) {
-               dbg_hid("Could not allocate quirks_list_struct\n");
+       if (!q_new)
                return -ENOMEM;
-       }
 
        q_new->hid_bl_item.idVendor = idVendor;
        q_new->hid_bl_item.idProduct = idProduct;
@@ -306,10 +309,9 @@ int usbhid_quirks_init(char **quirks_param)
                                &idVendor, &idProduct, &quirks);
 
                if (m != 3 ||
-                               usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) {
-                       printk(KERN_WARNING
-                                       "Could not parse HID quirk module param %s\n",
-                                       quirks_param[n]);
+                   usbhid_modify_dquirk(idVendor, idProduct, quirks) != 0) {
+                       pr_warn("Could not parse HID quirk module param %s\n",
+                               quirks_param[n]);
                }
        }
 
index 700145b1508894f30a018aef278d15cfc458ef3a..a8baaf60e28a44934380757e24cae5c178d060bd 100644 (file)
 #endif
 #define HIDDEV_BUFFER_SIZE     2048
 
-struct hiddev {
-       int exist;
-       int open;
-       struct mutex existancelock;
-       wait_queue_head_t wait;
-       struct hid_device *hid;
-       struct list_head list;
-       spinlock_t list_lock;
-};
-
 struct hiddev_list {
        struct hiddev_usage_ref buffer[HIDDEV_BUFFER_SIZE];
        int head;
@@ -689,6 +679,7 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
 
        case HIDIOCINITREPORT:
                usbhid_init_reports(hid);
+               hiddev->initialized = true;
                r = 0;
                break;
 
@@ -790,6 +781,10 @@ static long hiddev_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
        case HIDIOCGUSAGES:
        case HIDIOCSUSAGES:
        case HIDIOCGCOLLECTIONINDEX:
+               if (!hiddev->initialized) {
+                       usbhid_init_reports(hid);
+                       hiddev->initialized = true;
+               }
                r = hiddev_ioctl_usage(hiddev, cmd, user_arg);
                break;
 
@@ -910,6 +905,15 @@ int hiddev_connect(struct hid_device *hid, unsigned int force)
                kfree(hiddev);
                return -1;
        }
+
+       /*
+        * If HID_QUIRK_NO_INIT_REPORTS is set, make sure we don't initialize
+        * the reports.
+        */
+       hiddev->initialized = hid->quirks & HID_QUIRK_NO_INIT_REPORTS;
+
+       hiddev->minor = usbhid->intf->minor;
+
        return 0;
 }
 
index 037b9c04745a1a0474113176a7599c1dcb5055d0..0022c0dac88a20c79e4d080cbbdd35850ab36712 100644 (file)
@@ -2174,6 +2174,14 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
 
        wacom_update_name(wacom, wireless ? " (WL)" : "");
 
+       /* pen only Bamboo neither support touch nor pad */
+       if ((features->type == BAMBOO_PEN) &&
+           ((features->device_type & WACOM_DEVICETYPE_TOUCH) ||
+           (features->device_type & WACOM_DEVICETYPE_PAD))) {
+               error = -ENODEV;
+               goto fail;
+       }
+
        error = wacom_add_shared_data(hdev);
        if (error)
                goto fail;
@@ -2217,14 +2225,8 @@ static int wacom_parse_and_register(struct wacom *wacom, bool wireless)
        /* touch only Bamboo doesn't support pen */
        if ((features->type == BAMBOO_TOUCH) &&
            (features->device_type & WACOM_DEVICETYPE_PEN)) {
-               error = -ENODEV;
-               goto fail_quirks;
-       }
-
-       /* pen only Bamboo neither support touch nor pad */
-       if ((features->type == BAMBOO_PEN) &&
-           ((features->device_type & WACOM_DEVICETYPE_TOUCH) ||
-           (features->device_type & WACOM_DEVICETYPE_PAD))) {
+               cancel_delayed_work_sync(&wacom->init_work);
+               _wacom_query_tablet_data(wacom);
                error = -ENODEV;
                goto fail_quirks;
        }
@@ -2630,7 +2632,9 @@ static void wacom_remove(struct hid_device *hdev)
 
        /* make sure we don't trigger the LEDs */
        wacom_led_groups_release(wacom);
-       wacom_release_resources(wacom);
+
+       if (wacom->wacom_wac.features.type != REMOTE)
+               wacom_release_resources(wacom);
 
        hid_set_drvdata(hdev, NULL);
 }
index 6b8f6b81619595f62449ed6157cc878cb29d9d6a..4b225fb19a16842f635026d1b1023d5d1cf5068e 100644 (file)
@@ -2000,8 +2000,10 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
                input_set_capability(input, EV_KEY, BTN_TOOL_BRUSH);
                input_set_capability(input, EV_KEY, BTN_TOOL_PENCIL);
                input_set_capability(input, EV_KEY, BTN_TOOL_AIRBRUSH);
-               input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
-               input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
+               if (!(features->device_type & WACOM_DEVICETYPE_DIRECT)) {
+                       input_set_capability(input, EV_KEY, BTN_TOOL_MOUSE);
+                       input_set_capability(input, EV_KEY, BTN_TOOL_LENS);
+               }
                break;
        case WACOM_HID_WD_FINGERWHEEL:
                wacom_map_usage(input, usage, field, EV_ABS, ABS_WHEEL, 0);
@@ -2045,7 +2047,7 @@ static void wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field
                return;
        case HID_DG_TOOLSERIALNUMBER:
                wacom_wac->serial[0] = (wacom_wac->serial[0] & ~0xFFFFFFFFULL);
-               wacom_wac->serial[0] |= value;
+               wacom_wac->serial[0] |= (__u32)value;
                return;
        case WACOM_HID_WD_SENSE:
                wacom_wac->hid_data.sense_state = value;
@@ -2215,6 +2217,16 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
                wacom_wac->hid_data.cc_index = field->index;
                wacom_wac->hid_data.cc_value_index = usage->usage_index;
                break;
+       case HID_DG_CONTACTID:
+               if ((field->logical_maximum - field->logical_minimum) < touch_max) {
+                       /*
+                        * The HID descriptor for G11 sensors leaves logical
+                        * maximum set to '1' despite it being a multitouch
+                        * device. Override to a sensible number.
+                        */
+                       field->logical_maximum = 255;
+               }
+               break;
        }
 }
 
@@ -4245,10 +4257,10 @@ static const struct wacom_features wacom_features_0x343 =
          WACOM_DTU_OFFSET, WACOM_DTU_OFFSET };
 static const struct wacom_features wacom_features_0x360 =
        { "Wacom Intuos Pro M", 44800, 29600, 8191, 63,
-         INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 };
+         INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
 static const struct wacom_features wacom_features_0x361 =
        { "Wacom Intuos Pro L", 62200, 43200, 8191, 63,
-         INTUOSP2_BT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, 9, .touch_max = 10 };
+         INTUOSP2_BT, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 9, .touch_max = 10 };
 
 static const struct wacom_features wacom_features_HID_ANY_ID =
        { "Wacom HID", .type = HID_GENERIC, .oVid = HID_ANY_ID, .oPid = HID_ANY_ID };
index 28f38e2b8f309387b7a983937b50908c3095f7d9..5be325d890d96f9d823753e92296c379e3751076 100644 (file)
@@ -268,6 +268,8 @@ struct hid_item {
 #define HID_CP_APPLICATIONLAUNCHBUTTONS        0x000c0180
 #define HID_CP_GENERICGUIAPPLICATIONCONTROLS   0x000c0200
 
+#define HID_DG_DEVICECONFIG    0x000d000e
+#define HID_DG_DEVICESETTINGS  0x000d0023
 #define HID_DG_CONFIDENCE      0x000d0047
 #define HID_DG_WIDTH           0x000d0048
 #define HID_DG_HEIGHT          0x000d0049
@@ -322,7 +324,7 @@ struct hid_item {
 #define HID_QUIRK_MULTI_INPUT                  0x00000040
 #define HID_QUIRK_HIDINPUT_FORCE               0x00000080
 #define HID_QUIRK_NO_EMPTY_INPUT               0x00000100
-#define HID_QUIRK_NO_INIT_INPUT_REPORTS                0x00000200
+/* 0x00000200 reserved for backward compatibility, was NO_INIT_INPUT_REPORTS */
 #define HID_QUIRK_ALWAYS_POLL                  0x00000400
 #define HID_QUIRK_SKIP_OUTPUT_REPORTS          0x00010000
 #define HID_QUIRK_SKIP_OUTPUT_REPORT_ID                0x00020000
@@ -541,7 +543,6 @@ struct hid_device {                                                 /* device report descriptor */
        struct list_head inputs;                                        /* The list of inputs */
        void *hiddev;                                                   /* The hiddev structure */
        void *hidraw;
-       int minor;                                                      /* Hiddev minor number */
 
        int open;                                                       /* is the device open by anyone? */
        char name[128];                                                 /* Device name */
index a5dd8148660b7eb15482c99b1a602226007ec840..9216222229578075168262ac1c0cec5f88619f57 100644 (file)
  * In-kernel definitions.
  */
 
+struct hiddev {
+       int minor;
+       int exist;
+       int open;
+       struct mutex existancelock;
+       wait_queue_head_t wait;
+       struct hid_device *hid;
+       struct list_head list;
+       spinlock_t list_lock;
+       bool initialized;
+};
+
 struct hid_device;
 struct hid_usage;
 struct hid_field;
index 7aa901d920585949b2ecf6c546d65cb004daceea..1fb088239d12b9f4a5a849a2ce662343743c8bd9 100644 (file)
 
 #include <linux/types.h>
 
+struct regulator;
+
 /**
  * struct i2chid_platform_data - used by hid over i2c implementation.
  * @hid_descriptor_address: i2c register where the HID descriptor is stored.
+ * @supply: regulator for powering on the device.
+ * @post_power_delay_ms: delay after powering on before device is usable.
  *
  * Note that it is the responsibility of the platform driver (or the acpi 5.0
  * driver, or the flattened device tree) to setup the irq related to the gpio in
@@ -31,6 +35,8 @@
  */
 struct i2c_hid_platform_data {
        u16 hid_descriptor_address;
+       struct regulator *supply;
+       int post_power_delay_ms;
 };
 
 #endif /* __LINUX_I2C_HID_H */