diff options
| -rw-r--r-- | drivers/hid/hid-wacom.c | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index f9d493931b02..97ef6260fda0 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c | |||
| @@ -30,6 +30,7 @@ | |||
| 30 | struct wacom_data { | 30 | struct wacom_data { |
| 31 | __u16 tool; | 31 | __u16 tool; |
| 32 | unsigned char butstate; | 32 | unsigned char butstate; |
| 33 | unsigned char high_speed; | ||
| 33 | #ifdef CONFIG_HID_WACOM_POWER_SUPPLY | 34 | #ifdef CONFIG_HID_WACOM_POWER_SUPPLY |
| 34 | int battery_capacity; | 35 | int battery_capacity; |
| 35 | struct power_supply battery; | 36 | struct power_supply battery; |
| @@ -105,6 +106,7 @@ static int wacom_ac_get_property(struct power_supply *psy, | |||
| 105 | 106 | ||
| 106 | static void wacom_poke(struct hid_device *hdev, u8 speed) | 107 | static void wacom_poke(struct hid_device *hdev, u8 speed) |
| 107 | { | 108 | { |
| 109 | struct wacom_data *wdata = hid_get_drvdata(hdev); | ||
| 108 | int limit, ret; | 110 | int limit, ret; |
| 109 | char rep_data[2]; | 111 | char rep_data[2]; |
| 110 | 112 | ||
| @@ -128,8 +130,10 @@ static void wacom_poke(struct hid_device *hdev, u8 speed) | |||
| 128 | HID_FEATURE_REPORT); | 130 | HID_FEATURE_REPORT); |
| 129 | } while (ret < 0 && limit-- > 0); | 131 | } while (ret < 0 && limit-- > 0); |
| 130 | 132 | ||
| 131 | if (ret >= 0) | 133 | if (ret >= 0) { |
| 134 | wdata->high_speed = speed; | ||
| 132 | return; | 135 | return; |
| 136 | } | ||
| 133 | } | 137 | } |
| 134 | 138 | ||
| 135 | /* | 139 | /* |
| @@ -141,6 +145,35 @@ static void wacom_poke(struct hid_device *hdev, u8 speed) | |||
| 141 | return; | 145 | return; |
| 142 | } | 146 | } |
| 143 | 147 | ||
| 148 | static ssize_t wacom_show_speed(struct device *dev, | ||
| 149 | struct device_attribute | ||
| 150 | *attr, char *buf) | ||
| 151 | { | ||
| 152 | struct wacom_data *wdata = dev_get_drvdata(dev); | ||
| 153 | |||
| 154 | return snprintf(buf, PAGE_SIZE, "%i\n", wdata->high_speed); | ||
| 155 | } | ||
| 156 | |||
| 157 | static ssize_t wacom_store_speed(struct device *dev, | ||
| 158 | struct device_attribute *attr, | ||
| 159 | const char *buf, size_t count) | ||
| 160 | { | ||
| 161 | struct hid_device *hdev = container_of(dev, struct hid_device, dev); | ||
| 162 | int new_speed; | ||
| 163 | |||
| 164 | if (sscanf(buf, "%1d", &new_speed ) != 1) | ||
| 165 | return -EINVAL; | ||
| 166 | |||
| 167 | if (new_speed == 0 || new_speed == 1) { | ||
| 168 | wacom_poke(hdev, new_speed); | ||
| 169 | return strnlen(buf, PAGE_SIZE); | ||
| 170 | } else | ||
| 171 | return -EINVAL; | ||
| 172 | } | ||
| 173 | |||
| 174 | static DEVICE_ATTR(speed, S_IRUGO | S_IWUGO, | ||
| 175 | wacom_show_speed, wacom_store_speed); | ||
| 176 | |||
| 144 | static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, | 177 | static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report, |
| 145 | u8 *raw_data, int size) | 178 | u8 *raw_data, int size) |
| 146 | { | 179 | { |
| @@ -297,6 +330,11 @@ static int wacom_probe(struct hid_device *hdev, | |||
| 297 | goto err_free; | 330 | goto err_free; |
| 298 | } | 331 | } |
| 299 | 332 | ||
| 333 | ret = device_create_file(&hdev->dev, &dev_attr_speed); | ||
| 334 | if (ret) | ||
| 335 | dev_warn(&hdev->dev, | ||
| 336 | "can't create sysfs speed attribute err: %d\n", ret); | ||
| 337 | |||
| 300 | /* Set Wacom mode 2 with high reporting speed */ | 338 | /* Set Wacom mode 2 with high reporting speed */ |
| 301 | wacom_poke(hdev, 1); | 339 | wacom_poke(hdev, 1); |
| 302 | 340 | ||
