Commit d70a2ffe3a8ce37eeeecbed34e5b7a177956d535
Committed by
Jiri Kosina
1 parent
be4925b018
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
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>
Showing 1 changed file with 47 additions and 55 deletions Side-by-side Diff
drivers/hid/hid-wacom.c
... | ... | @@ -231,45 +231,12 @@ |
231 | 231 | static void wacom_set_features(struct hid_device *hdev, u8 speed) |
232 | 232 | { |
233 | 233 | struct wacom_data *wdata = hid_get_drvdata(hdev); |
234 | - int ret; | |
234 | + int limit, ret; | |
235 | 235 | __u8 rep_data[2]; |
236 | 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; | |
257 | - char 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 | - | |
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 | 240 | limit = 3; |
274 | 241 | do { |
275 | 242 | ret = hdev->hid_output_raw_report(hdev, rep_data, 2, |
276 | 243 | |
277 | 244 | |
... | ... | @@ -277,17 +244,47 @@ |
277 | 244 | } while (ret < 0 && limit-- > 0); |
278 | 245 | |
279 | 246 | if (ret >= 0) { |
280 | - wdata->high_speed = speed; | |
281 | - return; | |
247 | + if (speed == 0) | |
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 | 288 | return; |
292 | 289 | } |
293 | 290 | |
... | ... | @@ -311,7 +308,7 @@ |
311 | 308 | return -EINVAL; |
312 | 309 | |
313 | 310 | if (new_speed == 0 || new_speed == 1) { |
314 | - wacom_poke(hdev, new_speed); | |
311 | + wacom_set_features(hdev, new_speed); | |
315 | 312 | return strnlen(buf, PAGE_SIZE); |
316 | 313 | } else |
317 | 314 | return -EINVAL; |
318 | 315 | |
319 | 316 | |
... | ... | @@ -720,22 +717,17 @@ |
720 | 717 | hid_warn(hdev, |
721 | 718 | "can't create sysfs speed attribute err: %d\n", ret); |
722 | 719 | |
723 | - switch (hdev->product) { | |
724 | - case USB_DEVICE_ID_WACOM_GRAPHIRE_BLUETOOTH: | |
725 | - /* Set Wacom mode 2 with high reporting speed */ | |
726 | - wacom_poke(hdev, 1); | |
727 | - break; | |
728 | - case USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH: | |
720 | + wdata->features = 0; | |
721 | + wacom_set_features(hdev, 1); | |
722 | + | |
723 | + if (hdev->product == USB_DEVICE_ID_WACOM_INTUOS4_BLUETOOTH) { | |
729 | 724 | sprintf(hdev->name, "%s", "Wacom Intuos4 WL"); |
730 | - wdata->features = 0; | |
731 | - wacom_set_features(hdev, 1); | |
732 | 725 | ret = wacom_initialize_leds(hdev); |
733 | 726 | if (ret) { |
734 | 727 | hid_warn(hdev, |
735 | 728 | "can't create led attribute, err: %d\n", ret); |
736 | 729 | goto destroy_leds; |
737 | 730 | } |
738 | - break; | |
739 | 731 | } |
740 | 732 | |
741 | 733 | wdata->battery.properties = wacom_battery_props; |