aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2012-10-03 20:25:35 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2012-10-05 02:09:32 -0400
commitfe494bc2f6e47f02a78ec4761117187db40381a6 (patch)
tree05d31e702033a0b7a68f468097a8e9f086a9f246 /drivers/input
parent115d5e12a7d5fe62076f9dcc728905196162d709 (diff)
Input: wacom - clean up wacom_query_tablet_data
Rewrites this function to be easier to read and understand. The new function 'wacom_set_device_mode' now handles the grunt work of assembling the proper feature report, sending it to the device, and ensuring the setting "sticks". Signed-off-by: Jason Gerecke <killertofu@gmail.com> Tested-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/tablet/wacom_sys.c74
1 files changed, 35 insertions, 39 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index b44bba2a60c2..9edf9806cff9 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -502,56 +502,52 @@ static int wacom_parse_hid(struct usb_interface *intf,
502 return result; 502 return result;
503} 503}
504 504
505static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features) 505static int wacom_set_device_mode(struct usb_interface *intf, int report_id, int length, int mode)
506{ 506{
507 unsigned char *rep_data; 507 unsigned char *rep_data;
508 int limit = 0, report_id = 2; 508 int error = -ENOMEM, limit = 0;
509 int error = -ENOMEM;
510 509
511 rep_data = kmalloc(4, GFP_KERNEL); 510 rep_data = kzalloc(length, GFP_KERNEL);
512 if (!rep_data) 511 if (!rep_data)
513 return error; 512 return error;
514 513
515 /* ask to report Wacom data */ 514 rep_data[0] = report_id;
515 rep_data[1] = mode;
516
517 do {
518 error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
519 report_id, rep_data, length, 1);
520 if (error >= 0)
521 error = wacom_get_report(intf, WAC_HID_FEATURE_REPORT,
522 report_id, rep_data, length, 1);
523 } while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES);
524
525 kfree(rep_data);
526
527 return error < 0 ? error : 0;
528}
529
530/*
531 * Switch the tablet into its most-capable mode. Wacom tablets are
532 * typically configured to power-up in a mode which sends mouse-like
533 * reports to the OS. To get absolute position, pressure data, etc.
534 * from the tablet, it is necessary to switch the tablet out of this
535 * mode and into one which sends the full range of tablet data.
536 */
537static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features)
538{
516 if (features->device_type == BTN_TOOL_FINGER) { 539 if (features->device_type == BTN_TOOL_FINGER) {
517 /* if it is an MT Tablet PC touch */
518 if (features->type > TABLETPC) { 540 if (features->type > TABLETPC) {
519 do { 541 /* MT Tablet PC touch */
520 rep_data[0] = 3; 542 return wacom_set_device_mode(intf, 3, 4, 4);
521 rep_data[1] = 4; 543 }
522 rep_data[2] = 0; 544 } else if (features->device_type == BTN_TOOL_PEN) {
523 rep_data[3] = 0; 545 if (features->type <= BAMBOO_PT && features->type != WIRELESS) {
524 report_id = 3; 546 return wacom_set_device_mode(intf, 2, 2, 2);
525 error = wacom_set_report(intf,
526 WAC_HID_FEATURE_REPORT,
527 report_id,
528 rep_data, 4, 1);
529 if (error >= 0)
530 error = wacom_get_report(intf,
531 WAC_HID_FEATURE_REPORT,
532 report_id,
533 rep_data, 4, 1);
534 } while ((error < 0 || rep_data[1] != 4) &&
535 limit++ < WAC_MSG_RETRIES);
536 } 547 }
537 } else if (features->type <= BAMBOO_PT &&
538 features->type != WIRELESS &&
539 features->device_type == BTN_TOOL_PEN) {
540 do {
541 rep_data[0] = 2;
542 rep_data[1] = 2;
543 error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
544 report_id, rep_data, 2, 1);
545 if (error >= 0)
546 error = wacom_get_report(intf,
547 WAC_HID_FEATURE_REPORT,
548 report_id, rep_data, 2, 1);
549 } while ((error < 0 || rep_data[1] != 2) && limit++ < WAC_MSG_RETRIES);
550 } 548 }
551 549
552 kfree(rep_data); 550 return 0;
553
554 return error < 0 ? error : 0;
555} 551}
556 552
557static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, 553static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,