Ignore:
Timestamp:
Apr 14, 2017, 9:41:36 PM (6 weeks ago)
Author:
brainslayer
Message:

kernel update

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/linux/universal/linux-4.9/drivers/hid/i2c-hid/i2c-hid.c

    r31574 r31859  
    4242#include <linux/i2c/i2c-hid.h>
    4343
     44#include "../hid-ids.h"
     45
     46/* quirks to control the device */
     47#define I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV        BIT(0)
     48
    4449/* flags */
    4550#define I2C_HID_STARTED         0
     
    144149
    145150        unsigned long           flags;          /* device flags */
     151        unsigned long           quirks;         /* Various quirks */
    146152
    147153        wait_queue_head_t       wait;           /* For waiting the interrupt */
     
    154160        struct mutex            reset_lock;
    155161};
     162
     163static const struct i2c_hid_quirks {
     164        __u16 idVendor;
     165        __u16 idProduct;
     166        __u32 quirks;
     167} i2c_hid_quirks[] = {
     168        { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8752,
     169                I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV },
     170        { USB_VENDOR_ID_WEIDA, USB_DEVICE_ID_WEIDA_8755,
     171                I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV },
     172        { 0, 0 }
     173};
     174
     175/*
     176 * i2c_hid_lookup_quirk: return any quirks associated with a I2C HID device
     177 * @idVendor: the 16-bit vendor ID
     178 * @idProduct: the 16-bit product ID
     179 *
     180 * Returns: a u32 quirks value.
     181 */
     182static u32 i2c_hid_lookup_quirk(const u16 idVendor, const u16 idProduct)
     183{
     184        u32 quirks = 0;
     185        int n;
     186
     187        for (n = 0; i2c_hid_quirks[n].idVendor; n++)
     188                if (i2c_hid_quirks[n].idVendor == idVendor &&
     189                    (i2c_hid_quirks[n].idProduct == (__u16)HID_ANY_ID ||
     190                     i2c_hid_quirks[n].idProduct == idProduct))
     191                        quirks = i2c_hid_quirks[n].quirks;
     192
     193        return quirks;
     194}
    156195
    157196static int __i2c_hid_command(struct i2c_client *client,
     
    347386        i2c_hid_dbg(ihid, "%s\n", __func__);
    348387
     388        /*
     389         * Some devices require to send a command to wakeup before power on.
     390         * The call will get a return value (EREMOTEIO) but device will be
     391         * triggered and activated. After that, it goes like a normal device.
     392         */
     393        if (power_state == I2C_HID_PWR_ON &&
     394            ihid->quirks & I2C_HID_QUIRK_SET_PWR_WAKEUP_DEV) {
     395                ret = i2c_hid_command(client, &hid_set_power_cmd, NULL, 0);
     396
     397                /* Device was already activated */
     398                if (!ret)
     399                        goto set_pwr_exit;
     400        }
     401
    349402        ret = __i2c_hid_command(client, &hid_set_power_cmd, power_state,
    350403                0, NULL, 0, NULL, 0);
     404
    351405        if (ret)
    352406                dev_err(&client->dev, "failed to change power setting.\n");
    353407
     408set_pwr_exit:
    354409        return ret;
    355410}
     
    10511106        strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
    10521107
     1108        ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product);
     1109
    10531110        ret = hid_add_device(hid);
    10541111        if (ret) {
Note: See TracChangeset for help on using the changeset viewer.