diff options
| author | Przemo Firszt <przemo@firszt.eu> | 2012-05-15 14:32:28 -0400 |
|---|---|---|
| committer | Jiri Kosina <jkosina@suse.cz> | 2012-05-16 15:42:16 -0400 |
| commit | d70a2ffe3a8ce37eeeecbed34e5b7a177956d535 (patch) | |
| tree | 49d23e4b8619093a8e4c5e00ea5326d1cbb4ca1b | |
| parent | be4925b018b3c398d2775826091c693f214630a8 (diff) | |
HID: wacom: Unify speed setting
This patch unifies speed setting for both supported tablets. Functionality
of "wacom_poke" (used only by Graphire) is now in "wacom_set_features".
Reporting speed for both tablets can be changed by somethinkg like:
echo 1 > /sys/class/bluetooth/hci0/hci0:1/{device No}/speed
Accepted values:
0 - low speed,
1 - high speed.
The way of changing reporting speed is the same for Graphire and Intuos4 WL.
Signed-off-by: Przemo Firszt <przemo@firszt.eu>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
| -rw-r--r-- | drivers/hid/hid-wacom.c | 102 |
1 files changed, 47 insertions, 55 deletions
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c index 5f6ce70c23fb..fe23a1eb586b 100644 --- a/drivers/hid/hid-wacom.c +++ b/drivers/hid/hid-wacom.c | |||
| @@ -231,45 +231,12 @@ static int wacom_ac_get_property(struct power_supply *psy, | |||
| 231 | static void wacom_set_features(struct hid_device *hdev, u8 speed) | 231 | static void wacom_set_features(struct hid_device *hdev, u8 speed) |
| 232 | { | 232 | { |
| 233 | struct wacom_data *wdata = hid_get_drvdata(hdev); | 233 | struct wacom_data *wdata = hid_get_drvdata(hdev); |
| 234 | int ret; | ||
| 235 | __u8 rep_data[2]; | ||
| 236 | |||
| 237 | if (speed == 1) | ||
| 238 | wdata->features &= ~0x20; | ||
| 239 | else | ||
| 240 | wdata->features |= 0x20; | ||
| 241 | |||
| 242 | rep_data[0] = 0x03; | ||
| 243 | rep_data[1] = wdata->features; | ||
| 244 | |||
| 245 | ret = hdev->hid_output_raw_report(hdev, rep_data, 2, | ||
| 246 | HID_FEATURE_REPORT); | ||
| 247 | if (ret >= 0) | ||
| 248 | wdata->high_speed = speed; | ||
| 249 | |||
| 250 | return; | ||
| 251 | } | ||
| 252 | |||
| 253 | static void wacom_poke(struct hid_device *hdev, u8 speed) | ||
| 254 | { | ||
| 255 | struct wacom_data *wdata = hid_get_drvdata(hdev); | ||
| 256 | int limit, ret; | 234 | int limit, ret; |
| 257 | char rep_data[2]; | 235 | __u8 rep_data[2]; |
| 258 | |||
| 259 | rep_data[0] = 0x03 ; rep_data[1] = 0x00; | ||
| 260 | limit = 3; | ||
| 261 | do { | ||
| 262 | ret = hdev->hid_output_raw_report(hdev, rep_data, 2, | ||
| 263 | HID_FEATURE_REPORT); | ||
| 264 | } while (ret < 0 && limit-- > 0); | ||
| 265 | |||
| 266 | if (ret >= 0) { | ||
| 267 | if (speed == 0) | ||
| 268 | rep_data[0] = 0x05; | ||
| 269 | else | ||
| 270 | rep_data[0] = 0x06; | ||
| 271 | 236 | ||
| 272 | rep_data[1] = 0x00; | 237 | switch (hdev->product) { |
| 238 | case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: | ||
| 239 | rep_data[0] = 0x03 ; rep_data[1] = 0x00; | ||
| 273 | limit = 3; | 240 | limit = 3; |
| 274 | do { | 241 | do { |
| 275 | ret = hdev->hid_output_raw_report(hdev, rep_data, 2, | 242 | ret = hdev->hid_output_raw_report(hdev, rep_data, 2, |
| @@ -277,17 +244,47 @@ static void wacom_poke(struct hid_device *hdev, u8 speed) | |||
| 277 | } while (ret < 0 && limit-- > 0); | 244 | } while (ret < 0 && limit-- > 0); |
| 278 | 245 | ||
| 279 | if (ret >= 0) { | 246 | if (ret >= 0) { |
| 280 | wdata->high_speed = speed; | 247 | if (speed == 0) |
| 281 | return; | 248 | rep_data[0] = 0x05; |
| 249 | else | ||
| 250 | rep_data[0] = 0x06; | ||
| 251 | |||
| 252 | rep_data[1] = 0x00; | ||
| 253 | limit = 3; | ||
| 254 | do { | ||
| 255 | ret = hdev->hid_output_raw_report(hdev, | ||
| 256 | rep_data, 2, HID_FEATURE_REPORT); | ||
| 257 | } while (ret < 0 && limit-- > 0); | ||
| 258 | |||
| 259 | if (ret >= 0) { | ||
| 260 | wdata->high_speed = speed; | ||
| 261 | return; | ||
| 262 | } | ||
| 282 | } | 263 | } |
| 264 | |||
| 265 | /* | ||
| 266 | * Note that if the raw queries fail, it's not a hard failure | ||
| 267 | * and it is safe to continue | ||
| 268 | */ | ||
| 269 | hid_warn(hdev, "failed to poke device, command %d, err %d\n", | ||
| 270 | rep_data[0], ret); | ||
| 271 | break; | ||
| 272 | case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: | ||
| 273 | if (speed == 1) | ||
| 274 | wdata->features &= ~0x20; | ||
| 275 | else | ||
| 276 | wdata->features |= 0x20; | ||
| 277 | |||
| 278 | rep_data[0] = 0x03; | ||
| 279 | rep_data[1] = wdata->features; | ||
| 280 | |||
| 281 | ret = hdev->hid_output_raw_report(hdev, rep_data, 2, | ||
| 282 | HID_FEATURE_REPORT); | ||
| 283 | if (ret >= 0) | ||
| 284 | wdata->high_speed = speed; | ||
| 285 | break; | ||
| 283 | } | 286 | } |
| 284 | 287 | ||
| 285 | /* | ||
| 286 | * Note that if the raw queries fail, it's not a hard failure and it | ||
| 287 | * is safe to continue | ||
| 288 | */ | ||
| 289 | hid_warn(hdev, "failed to poke device, command %d, err %d\n", | ||
| 290 | rep_data[0], ret); | ||
| 291 | return; | 288 | return; |
| 292 | } | 289 | } |
| 293 | 290 | ||
| @@ -311,7 +308,7 @@ static ssize_t wacom_store_speed(struct device *dev, | |||
| 311 | return -EINVAL; | 308 | return -EINVAL; |
| 312 | 309 | ||
| 313 | if (new_speed == 0 || new_speed == 1) { | 310 | if (new_speed == 0 || new_speed == 1) { |
| 314 | wacom_poke(hdev, new_speed); | 311 | wacom_set_features(hdev, new_speed); |
| 315 | return strnlen(buf, PAGE_SIZE); | 312 | return strnlen(buf, PAGE_SIZE); |
| 316 | } else | 313 | } else |
| 317 | return -EINVAL; | 314 | return -EINVAL; |
| @@ -720,22 +717,17 @@ static int wacom_probe(struct hid_device *hdev, | |||
| 720 | hid_warn(hdev, | 717 | hid_warn(hdev, |
| 721 | "can't create sysfs speed attribute err: %d\n", ret); | 718 | "can't create sysfs speed attribute err: %d\n", ret); |
| 722 | 719 | ||
| 723 | switch (hdev->product) { | 720 | wdata->features = 0; |
| 724 | case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: | 721 | wacom_set_features(hdev, 1); |
| 725 | /* Set Wacom mode 2 with high reporting speed */ | 722 | |
| 726 | wacom_poke(hdev, 1); | 723 | if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) { |
| 727 | break; | ||
| 728 | case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: | ||
| 729 | sprintf(hdev->name, "%s", "Wacom Intuos4 WL"); | 724 | sprintf(hdev->name, "%s", "Wacom Intuos4 WL"); |
| 730 | wdata->features = 0; | ||
| 731 | wacom_set_features(hdev, 1); | ||
| 732 | ret = wacom_initialize_leds(hdev); | 725 | ret = wacom_initialize_leds(hdev); |
| 733 | if (ret) { | 726 | if (ret) { |
| 734 | hid_warn(hdev, | 727 | hid_warn(hdev, |
| 735 | "can't create led attribute, err: %d\n", ret); | 728 | "can't create led attribute, err: %d\n", ret); |
| 736 | goto destroy_leds; | 729 | goto destroy_leds; |
| 737 | } | 730 | } |
| 738 | break; | ||
| 739 | } | 731 | } |
| 740 | 732 | ||
| 741 | wdata->battery.properties = wacom_battery_props; | 733 | wdata->battery.properties = wacom_battery_props; |
