aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Bagwell <chris@cnpbagwell.com>2010-09-12 03:11:35 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2010-09-12 03:13:32 -0400
commit2aaacb153689dbe9064e4db7e9d00de0edfc1fa0 (patch)
tree0d4a108f6da71d2e3109d4f4456bc44b0befe1f2
parente1d38e49ad97eec5024342e1244279b645e36688 (diff)
Input: wacom - add support for Bamboo Pen
This adds support for Pen on Bamboo Pen and Bamboo Pen&Touch devices. Touchpad is handled by previous Bamboo Touch logic. Signed-off-by: Chris Bagwell <chris@cnpbagwell.com> Acked-by: Ping Cheng <pingc@wacom.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
-rw-r--r--drivers/input/tablet/wacom_wac.c79
1 files changed, 79 insertions, 0 deletions
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 2f7ed9a631b9..536156baedfe 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -904,10 +904,75 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
904 return 0; 904 return 0;
905} 905}
906 906
907static int wacom_bpt_pen(struct wacom_wac *wacom)
908{
909 struct input_dev *input = wacom->input;
910 unsigned char *data = wacom->data;
911 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
912
913 /*
914 * Similar to Graphire protocol, data[1] & 0x20 is proximity and
915 * data[1] & 0x18 is tool ID. 0x30 is safety check to ignore
916 * 2 unused tool ID's.
917 */
918 prox = (data[1] & 0x30) == 0x30;
919
920 /*
921 * All reports shared between PEN and RUBBER tool must be
922 * forced to a known starting value (zero) when transitioning to
923 * out-of-prox.
924 *
925 * If not reset then, to userspace, it will look like lost events
926 * if new tool comes in-prox with same values as previous tool sent.
927 *
928 * Hardware does report zero in most out-of-prox cases but not all.
929 */
930 if (prox) {
931 if (!wacom->shared->stylus_in_proximity) {
932 if (data[1] & 0x08) {
933 wacom->tool[0] = BTN_TOOL_RUBBER;
934 wacom->id[0] = ERASER_DEVICE_ID;
935 } else {
936 wacom->tool[0] = BTN_TOOL_PEN;
937 wacom->id[0] = STYLUS_DEVICE_ID;
938 }
939 wacom->shared->stylus_in_proximity = true;
940 }
941 x = le16_to_cpup((__le16 *)&data[2]);
942 y = le16_to_cpup((__le16 *)&data[4]);
943 p = le16_to_cpup((__le16 *)&data[6]);
944 d = data[8];
945 pen = data[1] & 0x01;
946 btn1 = data[1] & 0x02;
947 btn2 = data[1] & 0x04;
948 }
949
950 input_report_key(input, BTN_TOUCH, pen);
951 input_report_key(input, BTN_STYLUS, btn1);
952 input_report_key(input, BTN_STYLUS2, btn2);
953
954 input_report_abs(input, ABS_X, x);
955 input_report_abs(input, ABS_Y, y);
956 input_report_abs(input, ABS_PRESSURE, p);
957 input_report_abs(input, ABS_DISTANCE, d);
958
959 if (!prox) {
960 wacom->id[0] = 0;
961 wacom->shared->stylus_in_proximity = false;
962 }
963
964 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
965 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
966
967 return 1;
968}
969
907static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len) 970static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
908{ 971{
909 if (len == WACOM_PKGLEN_BBTOUCH) 972 if (len == WACOM_PKGLEN_BBTOUCH)
910 return wacom_bpt_touch(wacom); 973 return wacom_bpt_touch(wacom);
974 else if (len == WACOM_PKGLEN_BBFUN)
975 return wacom_bpt_pen(wacom);
911 976
912 return 0; 977 return 0;
913} 978}
@@ -1193,6 +1258,11 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1193 features->pressure_fuzz, 0); 1258 features->pressure_fuzz, 0);
1194 input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0, 1259 input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0,
1195 MAX_TRACKING_ID, 0, 0); 1260 MAX_TRACKING_ID, 0, 0);
1261 } else if (features->device_type == BTN_TOOL_PEN) {
1262 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1263 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1264 __set_bit(BTN_STYLUS, input_dev->keybit);
1265 __set_bit(BTN_STYLUS2, input_dev->keybit);
1196 } 1266 }
1197 break; 1267 break;
1198 } 1268 }
@@ -1334,6 +1404,12 @@ static const struct wacom_features wacom_features_0x47 =
1334 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }; 1404 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
1335static struct wacom_features wacom_features_0xD0 = 1405static struct wacom_features wacom_features_0xD0 =
1336 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT }; 1406 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1407static struct wacom_features wacom_features_0xD1 =
1408 { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1409static struct wacom_features wacom_features_0xD2 =
1410 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1411static struct wacom_features wacom_features_0xD3 =
1412 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1337 1413
1338#define USB_DEVICE_WACOM(prod) \ 1414#define USB_DEVICE_WACOM(prod) \
1339 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ 1415 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
@@ -1399,6 +1475,9 @@ const struct usb_device_id wacom_ids[] = {
1399 { USB_DEVICE_WACOM(0xC7) }, 1475 { USB_DEVICE_WACOM(0xC7) },
1400 { USB_DEVICE_WACOM(0xCE) }, 1476 { USB_DEVICE_WACOM(0xCE) },
1401 { USB_DEVICE_WACOM(0xD0) }, 1477 { USB_DEVICE_WACOM(0xD0) },
1478 { USB_DEVICE_WACOM(0xD1) },
1479 { USB_DEVICE_WACOM(0xD2) },
1480 { USB_DEVICE_WACOM(0xD3) },
1402 { USB_DEVICE_WACOM(0xF0) }, 1481 { USB_DEVICE_WACOM(0xF0) },
1403 { USB_DEVICE_WACOM(0xCC) }, 1482 { USB_DEVICE_WACOM(0xCC) },
1404 { USB_DEVICE_WACOM(0x90) }, 1483 { USB_DEVICE_WACOM(0x90) },