aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorNikolai Kondrashov <spbnick@gmail.com>2012-05-20 14:23:36 -0400
committerJiri Kosina <jkosina@suse.cz>2012-05-21 07:21:18 -0400
commited13794925786a64b2a21389d40a09e4012c357d (patch)
tree3acba453fb5bc1a475347dbc24b5c12d215305a0 /drivers
parentd2ee4dd9a4d68543bddddb69d38cba51b4373e6b (diff)
HID: waltop: Extend barrel button fix
Extend Waltop barrel button fix to all models: ignore reported pressure when a barrel button is pressed, because it is rarely correct. Report zero pressure in such cases instead. Signed-off-by: Nikolai Kondrashov <spbnick@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/hid/hid-waltop.c45
1 files changed, 7 insertions, 38 deletions
diff --git a/drivers/hid/hid-waltop.c b/drivers/hid/hid-waltop.c
index 9a48438090a9..745e4e9a8cf2 100644
--- a/drivers/hid/hid-waltop.c
+++ b/drivers/hid/hid-waltop.c
@@ -638,28 +638,10 @@ static __u8 sirius_battery_free_tablet_rdesc_fixed[] = {
638 0xC0 /* End Collection */ 638 0xC0 /* End Collection */
639}; 639};
640 640
641struct waltop_state {
642 u8 pressure0;
643 u8 pressure1;
644};
645
646static int waltop_probe(struct hid_device *hdev, 641static int waltop_probe(struct hid_device *hdev,
647 const struct hid_device_id *id) 642 const struct hid_device_id *id)
648{ 643{
649 int ret; 644 int ret;
650 struct waltop_state *s;
651
652 s = kzalloc(sizeof(*s), GFP_KERNEL);
653 if (s == NULL) {
654 hid_err(hdev, "can't allocate device state\n");
655 ret = -ENOMEM;
656 goto err;
657 }
658
659 s->pressure0 = 0;
660 s->pressure1 = 0;
661
662 hid_set_drvdata(hdev, s);
663 645
664 ret = hid_parse(hdev); 646 ret = hid_parse(hdev);
665 if (ret) { 647 if (ret) {
@@ -675,7 +657,6 @@ static int waltop_probe(struct hid_device *hdev,
675 657
676 return 0; 658 return 0;
677err: 659err:
678 kfree(s);
679 return ret; 660 return ret;
680} 661}
681 662
@@ -732,27 +713,18 @@ static __u8 *waltop_report_fixup(struct hid_device *hdev, __u8 *rdesc,
732static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report, 713static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report,
733 u8 *data, int size) 714 u8 *data, int size)
734{ 715{
735 /* If this is a pen input report of a tablet with PID 0038 */ 716 /* If this is a pen input report */
736 if (hdev->product == USB_DEVICE_ID_WALTOP_PID_0038 && 717 if (report->type == HID_INPUT_REPORT && report->id == 16 && size >= 8) {
737 report->type == HID_INPUT_REPORT &&
738 report->id == 16 &&
739 size == 8) {
740 struct waltop_state *s = hid_get_drvdata(hdev);
741
742 /* 718 /*
743 * Ignore maximum pressure reported when a barrel button is 719 * Ignore reported pressure when a barrel button is pressed,
744 * pressed. 720 * because it is rarely correct.
745 */ 721 */
746 722
747 /* If a barrel button is pressed */ 723 /* If a barrel button is pressed */
748 if ((data[1] & 0xF) > 1) { 724 if ((data[1] & 0xF) > 1) {
749 /* Use the last known pressure */ 725 /* Report zero pressure */
750 data[6] = s->pressure0; 726 data[6] = 0;
751 data[7] = s->pressure1; 727 data[7] = 0;
752 } else {
753 /* Remember reported pressure */
754 s->pressure0 = data[6];
755 s->pressure1 = data[7];
756 } 728 }
757 } 729 }
758 730
@@ -806,10 +778,7 @@ static int waltop_raw_event(struct hid_device *hdev, struct hid_report *report,
806 778
807static void waltop_remove(struct hid_device *hdev) 779static void waltop_remove(struct hid_device *hdev)
808{ 780{
809 struct waltop_state *s = hid_get_drvdata(hdev);
810
811 hid_hw_stop(hdev); 781 hid_hw_stop(hdev);
812 kfree(s);
813} 782}
814 783
815static const struct hid_device_id waltop_devices[] = { 784static const struct hid_device_id waltop_devices[] = {