aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet
diff options
context:
space:
mode:
authorPing Cheng <pinglinux@gmail.com>2011-03-12 23:34:11 -0500
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2011-03-12 23:37:16 -0500
commit8aa9a9ac89baa0e423da0211e0883d28165697e0 (patch)
tree8c94b29f3115720aaad80c845b6a28fe67eb5dc2 /drivers/input/tablet
parent4fc193814b3a269c1ea89aefdb56d4f957680d44 (diff)
Input: wacom - process pen data in its own routine
So it would be easier for patch reviewers to follow the data path. Reviewed-by: Henrik Rydberg <rydberg@euromail.se> Reviewed-by: Chris Bagwell <chris@cnpbagwell.com> Signed-off-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/tablet')
-rw-r--r--drivers/input/tablet/wacom_wac.c73
1 files changed, 40 insertions, 33 deletions
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 5488c6172621..15bab99a4c7e 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -722,13 +722,47 @@ static void wacom_tpc_touch_in(struct wacom_wac *wacom, size_t len)
722 } 722 }
723} 723}
724 724
725static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len) 725static int wacom_tpc_pen(struct wacom_wac *wacom)
726{ 726{
727 struct wacom_features *features = &wacom->features; 727 struct wacom_features *features = &wacom->features;
728 char *data = wacom->data; 728 char *data = wacom->data;
729 struct input_dev *input = wacom->input; 729 struct input_dev *input = wacom->input;
730 int prox = 0, pressure; 730 int prox, pressure;
731 int retval = 0; 731
732 prox = data[1] & 0x20;
733
734 if (!wacom->shared->stylus_in_proximity) { /* first in prox */
735 /* Going into proximity select tool */
736 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
737 if (wacom->tool[0] == BTN_TOOL_PEN)
738 wacom->id[0] = STYLUS_DEVICE_ID;
739 else
740 wacom->id[0] = ERASER_DEVICE_ID;
741
742 wacom->shared->stylus_in_proximity = true;
743 }
744 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
745 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
746 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
747 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
748 pressure = ((data[7] & 0x01) << 8) | data[6];
749 if (pressure < 0)
750 pressure = features->pressure_max + pressure + 1;
751 input_report_abs(input, ABS_PRESSURE, pressure);
752 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
753 if (!prox) { /* out-prox */
754 wacom->id[0] = 0;
755 wacom->shared->stylus_in_proximity = false;
756 }
757 input_report_key(input, wacom->tool[0], prox);
758
759 return 1;
760}
761
762static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
763{
764 char *data = wacom->data;
765 int prox = 0;
732 766
733 dbg("wacom_tpc_irq: received report #%d", data[0]); 767 dbg("wacom_tpc_irq: received report #%d", data[0]);
734 768
@@ -757,37 +791,10 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
757 } 791 }
758 /* keep prox bit to send proper out-prox event */ 792 /* keep prox bit to send proper out-prox event */
759 wacom->id[1] = prox; 793 wacom->id[1] = prox;
760 } else if (data[0] == WACOM_REPORT_PENABLED) { /* Penabled */ 794 } else if (data[0] == WACOM_REPORT_PENABLED)
761 prox = data[1] & 0x20; 795 return wacom_tpc_pen(wacom);
762
763 if (!wacom->shared->stylus_in_proximity) { /* first in prox */
764 /* Going into proximity select tool */
765 wacom->tool[0] = (data[1] & 0x0c) ? BTN_TOOL_RUBBER : BTN_TOOL_PEN;
766 if (wacom->tool[0] == BTN_TOOL_PEN)
767 wacom->id[0] = STYLUS_DEVICE_ID;
768 else
769 wacom->id[0] = ERASER_DEVICE_ID;
770 796
771 wacom->shared->stylus_in_proximity = true; 797 return 0;
772 }
773 input_report_key(input, BTN_STYLUS, data[1] & 0x02);
774 input_report_key(input, BTN_STYLUS2, data[1] & 0x10);
775 input_report_abs(input, ABS_X, le16_to_cpup((__le16 *)&data[2]));
776 input_report_abs(input, ABS_Y, le16_to_cpup((__le16 *)&data[4]));
777 pressure = ((data[7] & 0x01) << 8) | data[6];
778 if (pressure < 0)
779 pressure = features->pressure_max + pressure + 1;
780 input_report_abs(input, ABS_PRESSURE, pressure);
781 input_report_key(input, BTN_TOUCH, data[1] & 0x05);
782 if (!prox) { /* out-prox */
783 wacom->id[0] = 0;
784 wacom->shared->stylus_in_proximity = false;
785 }
786 input_report_key(input, wacom->tool[0], prox);
787 input_report_abs(input, ABS_MISC, wacom->id[0]);
788 retval = 1;
789 }
790 return retval;
791} 798}
792 799
793static int wacom_bpt_touch(struct wacom_wac *wacom) 800static int wacom_bpt_touch(struct wacom_wac *wacom)