diff options
author | Jason Gerecke <killertofu@gmail.com> | 2012-10-03 20:19:11 -0400 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2012-10-04 02:58:15 -0400 |
commit | 4e90495498cc6f1aa15e7667a695908860938b3e (patch) | |
tree | be5df2824e3bff577e4d56b368f6c070e040d891 /drivers | |
parent | 7774036808011ceecc88cef01dfafcce39ed9fc5 (diff) |
Input: wacom - report correct touch contact size for I5/Bamboo
This changes how the touch packets for Intuos5 and 3rd-gen Bamboo
are interpreted, so that proper values for the MAJOR and MINOR
axes are reported. Instead of using the amplitude field (data[6]),
we use the size field (data[5]) and do some calculation to
transform it from a scaled-down area into axis lengths.
Note that even though we assume a circular contact, both MAJOR and
MINOR are reported since the resolution of the X and Y axes differ.
Signed-off-by: Jason Gerecke <killertofu@gmail.com>
Reviewed-by: Chris Bagwell <chris@cnpbagwell.com>
Acked-by: Ping Cheng <pingc@wacom.com>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/input/tablet/wacom_wac.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c index 2a81ce375f75..ea4068b4490b 100644 --- a/drivers/input/tablet/wacom_wac.c +++ b/drivers/input/tablet/wacom_wac.c | |||
@@ -25,6 +25,11 @@ | |||
25 | #define WACOM_INTUOS_RES 100 | 25 | #define WACOM_INTUOS_RES 100 |
26 | #define WACOM_INTUOS3_RES 200 | 26 | #define WACOM_INTUOS3_RES 200 |
27 | 27 | ||
28 | /* Scale factor relating reported contact size to logical contact area. | ||
29 | * 2^14/pi is a good approximation on Intuos5 and 3rd-gen Bamboo | ||
30 | */ | ||
31 | #define WACOM_CONTACT_AREA_SCALE 2607 | ||
32 | |||
28 | static int wacom_penpartner_irq(struct wacom_wac *wacom) | 33 | static int wacom_penpartner_irq(struct wacom_wac *wacom) |
29 | { | 34 | { |
30 | unsigned char *data = wacom->data; | 35 | unsigned char *data = wacom->data; |
@@ -1043,11 +1048,19 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) | |||
1043 | if (touch) { | 1048 | if (touch) { |
1044 | int x = (data[2] << 4) | (data[4] >> 4); | 1049 | int x = (data[2] << 4) | (data[4] >> 4); |
1045 | int y = (data[3] << 4) | (data[4] & 0x0f); | 1050 | int y = (data[3] << 4) | (data[4] & 0x0f); |
1046 | int w = data[6]; | 1051 | int a = data[5]; |
1052 | |||
1053 | // "a" is a scaled-down area which we assume is roughly | ||
1054 | // circular and which can be described as: a=(pi*r^2)/C. | ||
1055 | int x_res = input_abs_get_res(input, ABS_X); | ||
1056 | int y_res = input_abs_get_res(input, ABS_Y); | ||
1057 | int width = 2 * int_sqrt(a * WACOM_CONTACT_AREA_SCALE); | ||
1058 | int height = width * y_res / x_res; | ||
1047 | 1059 | ||
1048 | input_report_abs(input, ABS_MT_POSITION_X, x); | 1060 | input_report_abs(input, ABS_MT_POSITION_X, x); |
1049 | input_report_abs(input, ABS_MT_POSITION_Y, y); | 1061 | input_report_abs(input, ABS_MT_POSITION_Y, y); |
1050 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, w); | 1062 | input_report_abs(input, ABS_MT_TOUCH_MAJOR, width); |
1063 | input_report_abs(input, ABS_MT_TOUCH_MINOR, height); | ||
1051 | } | 1064 | } |
1052 | } | 1065 | } |
1053 | 1066 | ||
@@ -1533,7 +1546,9 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1533 | input_mt_init_slots(input_dev, features->touch_max, 0); | 1546 | input_mt_init_slots(input_dev, features->touch_max, 0); |
1534 | 1547 | ||
1535 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, | 1548 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR, |
1536 | 0, 255, 0, 0); | 1549 | 0, features->x_max, 0, 0); |
1550 | input_set_abs_params(input_dev, ABS_MT_TOUCH_MINOR, | ||
1551 | 0, features->y_max, 0, 0); | ||
1537 | 1552 | ||
1538 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | 1553 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |
1539 | 0, features->x_max, | 1554 | 0, features->x_max, |
@@ -1641,7 +1656,10 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev, | |||
1641 | 1656 | ||
1642 | input_set_abs_params(input_dev, | 1657 | input_set_abs_params(input_dev, |
1643 | ABS_MT_TOUCH_MAJOR, | 1658 | ABS_MT_TOUCH_MAJOR, |
1644 | 0, 255, 0, 0); | 1659 | 0, features->x_max, 0, 0); |
1660 | input_set_abs_params(input_dev, | ||
1661 | ABS_MT_TOUCH_MINOR, | ||
1662 | 0, features->y_max, 0, 0); | ||
1645 | } | 1663 | } |
1646 | 1664 | ||
1647 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, | 1665 | input_set_abs_params(input_dev, ABS_MT_POSITION_X, |