]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - drivers/hid/i2c-hid/i2c-hid.c
HID: i2c-hid: Disable runtime PM for LG touchscreen
[mirror_ubuntu-bionic-kernel.git] / drivers / hid / i2c-hid / i2c-hid.c
index e054ee43c1e275da0adff1d6ee5e8ec49bb1ecbc..103916c6026cb057c811f179db063a276ac3d6f2 100644 (file)
@@ -47,6 +47,8 @@
 /* quirks to control the device */
 #define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV       BIT(0)
 #define I2C_HID_QUIRK_NO_IRQ_AFTER_RESET       BIT(1)
+#define I2C_HID_QUIRK_RESEND_REPORT_DESCR      BIT(2)
+#define I2C_HID_QUIRK_NO_RUNTIME_PM            BIT(3)
 
 /* flags */
 #define I2C_HID_STARTED                0
@@ -144,10 +146,10 @@ struct i2c_hid {
                                                   * register of the HID
                                                   * descriptor. */
        unsigned int            bufsize;        /* i2c buffer size */
-       char                    *inbuf;         /* Input buffer */
-       char                    *rawbuf;        /* Raw Input buffer */
-       char                    *cmdbuf;        /* Command buffer */
-       char                    *argsbuf;       /* Command arguments buffer */
+       u8                      *inbuf;         /* Input buffer */
+       u8                      *rawbuf;        /* Raw Input buffer */
+       u8                      *cmdbuf;        /* Command buffer */
+       u8                      *argsbuf;       /* Command arguments buffer */
 
        unsigned long           flags;          /* device flags */
        unsigned long           quirks;         /* Various quirks */
@@ -170,7 +172,12 @@ static const struct i2c_hid_quirks {
        { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8755,
                I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV },
        { I2C_VENDOR_ID_HANTICK, I2C_PRODUCT_ID_HANTICK_5288,
-               I2C_HID_QUIRK_NO_IRQ_AFTER_RESET },
+               I2C_HID_QUIRK_NO_IRQ_AFTER_RESET |
+               I2C_HID_QUIRK_NO_RUNTIME_PM },
+       { USB_VENDOR_ID_SIS_TOUCH, USB_DEVICE_ID_SIS10FB_TOUCH,
+               I2C_HID_QUIRK_RESEND_REPORT_DESCR },
+       { USB_VENDOR_ID_LG, I2C_DEVICE_ID_LG_8001,
+               I2C_HID_QUIRK_NO_RUNTIME_PM },
        { 0, 0 }
 };
 
@@ -455,7 +462,8 @@ out_unlock:
 
 static void i2c_hid_get_input(struct i2c_hid *ihid)
 {
-       int ret, ret_size;
+       int ret;
+       u32 ret_size;
        int size = le16_to_cpu(ihid->hdesc.wMaxInputLength);
 
        if (size > ihid->bufsize)
@@ -480,7 +488,7 @@ static void i2c_hid_get_input(struct i2c_hid *ihid)
                return;
        }
 
-       if (ret_size > size) {
+       if ((ret_size > size) || (ret_size < 2)) {
                dev_err(&ihid->client->dev, "%s: incomplete report (%d/%d)\n",
                        __func__, size, ret_size);
                return;
@@ -1077,7 +1085,9 @@ static int i2c_hid_probe(struct i2c_client *client,
                goto err_mem_free;
        }
 
-       pm_runtime_put(&client->dev);
+       if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM))
+               pm_runtime_put(&client->dev);
+
        return 0;
 
 err_mem_free:
@@ -1104,7 +1114,8 @@ static int i2c_hid_remove(struct i2c_client *client)
        struct i2c_hid *ihid = i2c_get_clientdata(client);
        struct hid_device *hid;
 
-       pm_runtime_get_sync(&client->dev);
+       if (!(ihid->quirks & I2C_HID_QUIRK_NO_RUNTIME_PM))
+               pm_runtime_get_sync(&client->dev);
        pm_runtime_disable(&client->dev);
        pm_runtime_set_suspended(&client->dev);
        pm_runtime_put_noidle(&client->dev);
@@ -1207,10 +1218,25 @@ static int i2c_hid_resume(struct device *dev)
        pm_runtime_enable(dev);
 
        enable_irq(client->irq);
-       ret = i2c_hid_hwreset(client);
+
+       /* Instead of resetting device, simply powers the device on. This
+        * solves "incomplete reports" on Raydium devices 2386:3118 and
+        * 2386:4B33
+        */
+       ret = i2c_hid_set_power(client, I2C_HID_PWR_ON);
        if (ret)
                return ret;
 
+       /* Some devices need to re-send report descr cmd
+        * after resume, after this it will be back normal.
+        * otherwise it issues too many incomplete reports.
+        */
+       if (ihid->quirks & I2C_HID_QUIRK_RESEND_REPORT_DESCR) {
+               ret = i2c_hid_command(client, &hid_report_descr_cmd, NULL, 0);
+               if (ret)
+                       return ret;
+       }
+
        if (hid->driver && hid->driver->reset_resume) {
                ret = hid->driver->reset_resume(hid);
                return ret;