aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet/wacom_wac.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/tablet/wacom_wac.c')
-rw-r--r--drivers/input/tablet/wacom_wac.c253
1 files changed, 239 insertions, 14 deletions
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 47fd7a041c52..b3252ef1e279 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -857,6 +857,134 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
857 return retval; 857 return retval;
858} 858}
859 859
860static int wacom_bpt_touch(struct wacom_wac *wacom)
861{
862 struct wacom_features *features = &wacom->features;
863 struct input_dev *input = wacom->input;
864 unsigned char *data = wacom->data;
865 int sp = 0, sx = 0, sy = 0, count = 0;
866 int i;
867
868 for (i = 0; i < 2; i++) {
869 int p = data[9 * i + 2];
870 input_mt_slot(input, i);
871 /*
872 * Touch events need to be disabled while stylus is
873 * in proximity because user's hand is resting on touchpad
874 * and sending unwanted events. User expects tablet buttons
875 * to continue working though.
876 */
877 if (p && !wacom->shared->stylus_in_proximity) {
878 int x = get_unaligned_be16(&data[9 * i + 3]) & 0x7ff;
879 int y = get_unaligned_be16(&data[9 * i + 5]) & 0x7ff;
880 if (features->quirks & WACOM_QUIRK_BBTOUCH_LOWRES) {
881 x <<= 5;
882 y <<= 5;
883 }
884 input_report_abs(input, ABS_MT_PRESSURE, p);
885 input_report_abs(input, ABS_MT_POSITION_X, x);
886 input_report_abs(input, ABS_MT_POSITION_Y, y);
887 if (wacom->id[i] < 0)
888 wacom->id[i] = wacom->trk_id++ & MAX_TRACKING_ID;
889 if (!count++)
890 sp = p, sx = x, sy = y;
891 } else {
892 wacom->id[i] = -1;
893 }
894 input_report_abs(input, ABS_MT_TRACKING_ID, wacom->id[i]);
895 }
896
897 input_report_key(input, BTN_TOUCH, count > 0);
898 input_report_key(input, BTN_TOOL_FINGER, count == 1);
899 input_report_key(input, BTN_TOOL_DOUBLETAP, count == 2);
900
901 input_report_abs(input, ABS_PRESSURE, sp);
902 input_report_abs(input, ABS_X, sx);
903 input_report_abs(input, ABS_Y, sy);
904
905 input_report_key(input, BTN_LEFT, (data[1] & 0x08) != 0);
906 input_report_key(input, BTN_FORWARD, (data[1] & 0x04) != 0);
907 input_report_key(input, BTN_BACK, (data[1] & 0x02) != 0);
908 input_report_key(input, BTN_RIGHT, (data[1] & 0x01) != 0);
909
910 input_sync(input);
911
912 return 0;
913}
914
915static int wacom_bpt_pen(struct wacom_wac *wacom)
916{
917 struct input_dev *input = wacom->input;
918 unsigned char *data = wacom->data;
919 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
920
921 /*
922 * Similar to Graphire protocol, data[1] & 0x20 is proximity and
923 * data[1] & 0x18 is tool ID. 0x30 is safety check to ignore
924 * 2 unused tool ID's.
925 */
926 prox = (data[1] & 0x30) == 0x30;
927
928 /*
929 * All reports shared between PEN and RUBBER tool must be
930 * forced to a known starting value (zero) when transitioning to
931 * out-of-prox.
932 *
933 * If not reset then, to userspace, it will look like lost events
934 * if new tool comes in-prox with same values as previous tool sent.
935 *
936 * Hardware does report zero in most out-of-prox cases but not all.
937 */
938 if (prox) {
939 if (!wacom->shared->stylus_in_proximity) {
940 if (data[1] & 0x08) {
941 wacom->tool[0] = BTN_TOOL_RUBBER;
942 wacom->id[0] = ERASER_DEVICE_ID;
943 } else {
944 wacom->tool[0] = BTN_TOOL_PEN;
945 wacom->id[0] = STYLUS_DEVICE_ID;
946 }
947 wacom->shared->stylus_in_proximity = true;
948 }
949 x = le16_to_cpup((__le16 *)&data[2]);
950 y = le16_to_cpup((__le16 *)&data[4]);
951 p = le16_to_cpup((__le16 *)&data[6]);
952 d = data[8];
953 pen = data[1] & 0x01;
954 btn1 = data[1] & 0x02;
955 btn2 = data[1] & 0x04;
956 }
957
958 input_report_key(input, BTN_TOUCH, pen);
959 input_report_key(input, BTN_STYLUS, btn1);
960 input_report_key(input, BTN_STYLUS2, btn2);
961
962 input_report_abs(input, ABS_X, x);
963 input_report_abs(input, ABS_Y, y);
964 input_report_abs(input, ABS_PRESSURE, p);
965 input_report_abs(input, ABS_DISTANCE, d);
966
967 if (!prox) {
968 wacom->id[0] = 0;
969 wacom->shared->stylus_in_proximity = false;
970 }
971
972 input_report_key(input, wacom->tool[0], prox); /* PEN or RUBBER */
973 input_report_abs(input, ABS_MISC, wacom->id[0]); /* TOOL ID */
974
975 return 1;
976}
977
978static int wacom_bpt_irq(struct wacom_wac *wacom, size_t len)
979{
980 if (len == WACOM_PKGLEN_BBTOUCH)
981 return wacom_bpt_touch(wacom);
982 else if (len == WACOM_PKGLEN_BBFUN)
983 return wacom_bpt_pen(wacom);
984
985 return 0;
986}
987
860void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len) 988void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
861{ 989{
862 bool sync; 990 bool sync;
@@ -902,6 +1030,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
902 sync = wacom_tpc_irq(wacom_wac, len); 1030 sync = wacom_tpc_irq(wacom_wac, len);
903 break; 1031 break;
904 1032
1033 case BAMBOO_PT:
1034 sync = wacom_bpt_irq(wacom_wac, len);
1035 break;
1036
905 default: 1037 default:
906 sync = false; 1038 sync = false;
907 break; 1039 break;
@@ -911,26 +1043,17 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
911 input_sync(wacom_wac->input); 1043 input_sync(wacom_wac->input);
912} 1044}
913 1045
914static void wacom_setup_intuos(struct wacom_wac *wacom_wac) 1046static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
915{ 1047{
916 struct input_dev *input_dev = wacom_wac->input; 1048 struct input_dev *input_dev = wacom_wac->input;
917 1049
918 input_set_capability(input_dev, EV_MSC, MSC_SERIAL); 1050 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
919 input_set_capability(input_dev, EV_REL, REL_WHEEL);
920
921 __set_bit(BTN_LEFT, input_dev->keybit);
922 __set_bit(BTN_RIGHT, input_dev->keybit);
923 __set_bit(BTN_MIDDLE, input_dev->keybit);
924 __set_bit(BTN_SIDE, input_dev->keybit);
925 __set_bit(BTN_EXTRA, input_dev->keybit);
926 1051
927 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1052 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
928 __set_bit(BTN_TOOL_PEN, input_dev->keybit); 1053 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
929 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
930 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit); 1054 __set_bit(BTN_TOOL_BRUSH, input_dev->keybit);
931 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit); 1055 __set_bit(BTN_TOOL_PENCIL, input_dev->keybit);
932 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit); 1056 __set_bit(BTN_TOOL_AIRBRUSH, input_dev->keybit);
933 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
934 __set_bit(BTN_STYLUS, input_dev->keybit); 1057 __set_bit(BTN_STYLUS, input_dev->keybit);
935 __set_bit(BTN_STYLUS2, input_dev->keybit); 1058 __set_bit(BTN_STYLUS2, input_dev->keybit);
936 1059
@@ -939,10 +1062,55 @@ static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
939 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0); 1062 input_set_abs_params(input_dev, ABS_WHEEL, 0, 1023, 0, 0);
940 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0); 1063 input_set_abs_params(input_dev, ABS_TILT_X, 0, 127, 0, 0);
941 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0); 1064 input_set_abs_params(input_dev, ABS_TILT_Y, 0, 127, 0, 0);
1065}
1066
1067static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
1068{
1069 struct input_dev *input_dev = wacom_wac->input;
1070
1071 input_set_capability(input_dev, EV_REL, REL_WHEEL);
1072
1073 wacom_setup_cintiq(wacom_wac);
1074
1075 __set_bit(BTN_LEFT, input_dev->keybit);
1076 __set_bit(BTN_RIGHT, input_dev->keybit);
1077 __set_bit(BTN_MIDDLE, input_dev->keybit);
1078 __set_bit(BTN_SIDE, input_dev->keybit);
1079 __set_bit(BTN_EXTRA, input_dev->keybit);
1080 __set_bit(BTN_TOOL_MOUSE, input_dev->keybit);
1081 __set_bit(BTN_TOOL_LENS, input_dev->keybit);
1082
942 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0); 1083 input_set_abs_params(input_dev, ABS_RZ, -900, 899, 0, 0);
943 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0); 1084 input_set_abs_params(input_dev, ABS_THROTTLE, -1023, 1023, 0, 0);
944} 1085}
945 1086
1087void wacom_setup_device_quirks(struct wacom_features *features)
1088{
1089
1090 /* touch device found but size is not defined. use default */
1091 if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) {
1092 features->x_max = 1023;
1093 features->y_max = 1023;
1094 }
1095
1096 /* these device have multiple inputs */
1097 if (features->type == TABLETPC || features->type == TABLETPC2FG ||
1098 features->type == BAMBOO_PT)
1099 features->quirks |= WACOM_QUIRK_MULTI_INPUT;
1100
1101 /* quirks for bamboo touch */
1102 if (features->type == BAMBOO_PT &&
1103 features->device_type == BTN_TOOL_TRIPLETAP) {
1104 features->x_max <<= 5;
1105 features->y_max <<= 5;
1106 features->x_fuzz <<= 5;
1107 features->y_fuzz <<= 5;
1108 features->pressure_max = 256;
1109 features->pressure_fuzz = 16;
1110 features->quirks |= WACOM_QUIRK_BBTOUCH_LOWRES;
1111 }
1112}
1113
946void wacom_setup_input_capabilities(struct input_dev *input_dev, 1114void wacom_setup_input_capabilities(struct input_dev *input_dev,
947 struct wacom_wac *wacom_wac) 1115 struct wacom_wac *wacom_wac)
948{ 1116{
@@ -953,9 +1121,12 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
953 1121
954 __set_bit(BTN_TOUCH, input_dev->keybit); 1122 __set_bit(BTN_TOUCH, input_dev->keybit);
955 1123
956 input_set_abs_params(input_dev, ABS_X, 0, features->x_max, 4, 0); 1124 input_set_abs_params(input_dev, ABS_X, 0, features->x_max,
957 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max, 4, 0); 1125 features->x_fuzz, 0);
958 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max, 0, 0); 1126 input_set_abs_params(input_dev, ABS_Y, 0, features->y_max,
1127 features->y_fuzz, 0);
1128 input_set_abs_params(input_dev, ABS_PRESSURE, 0, features->pressure_max,
1129 features->pressure_fuzz, 0);
959 1130
960 __set_bit(ABS_MISC, input_dev->absbit); 1131 __set_bit(ABS_MISC, input_dev->absbit);
961 1132
@@ -1005,9 +1176,19 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1005 __set_bit(BTN_9, input_dev->keybit); 1176 __set_bit(BTN_9, input_dev->keybit);
1006 /* fall through */ 1177 /* fall through */
1007 1178
1179 case CINTIQ:
1180 for (i = 0; i < 8; i++)
1181 __set_bit(BTN_0 + i, input_dev->keybit);
1182 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1183
1184 input_set_abs_params(input_dev, ABS_RX, 0, 4096, 0, 0);
1185 input_set_abs_params(input_dev, ABS_RY, 0, 4096, 0, 0);
1186 input_set_abs_params(input_dev, ABS_Z, -900, 899, 0, 0);
1187 wacom_setup_cintiq(wacom_wac);
1188 break;
1189
1008 case INTUOS3: 1190 case INTUOS3:
1009 case INTUOS3L: 1191 case INTUOS3L:
1010 case CINTIQ:
1011 __set_bit(BTN_4, input_dev->keybit); 1192 __set_bit(BTN_4, input_dev->keybit);
1012 __set_bit(BTN_5, input_dev->keybit); 1193 __set_bit(BTN_5, input_dev->keybit);
1013 __set_bit(BTN_6, input_dev->keybit); 1194 __set_bit(BTN_6, input_dev->keybit);
@@ -1078,6 +1259,38 @@ void wacom_setup_input_capabilities(struct input_dev *input_dev,
1078 case PENPARTNER: 1259 case PENPARTNER:
1079 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit); 1260 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1080 break; 1261 break;
1262
1263 case BAMBOO_PT:
1264 __clear_bit(ABS_MISC, input_dev->absbit);
1265
1266 if (features->device_type == BTN_TOOL_TRIPLETAP) {
1267 __set_bit(BTN_LEFT, input_dev->keybit);
1268 __set_bit(BTN_FORWARD, input_dev->keybit);
1269 __set_bit(BTN_BACK, input_dev->keybit);
1270 __set_bit(BTN_RIGHT, input_dev->keybit);
1271
1272 __set_bit(BTN_TOOL_FINGER, input_dev->keybit);
1273 __set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit);
1274
1275 input_mt_create_slots(input_dev, 2);
1276 input_set_abs_params(input_dev, ABS_MT_POSITION_X,
1277 0, features->x_max,
1278 features->x_fuzz, 0);
1279 input_set_abs_params(input_dev, ABS_MT_POSITION_Y,
1280 0, features->y_max,
1281 features->y_fuzz, 0);
1282 input_set_abs_params(input_dev, ABS_MT_PRESSURE,
1283 0, features->pressure_max,
1284 features->pressure_fuzz, 0);
1285 input_set_abs_params(input_dev, ABS_MT_TRACKING_ID, 0,
1286 MAX_TRACKING_ID, 0, 0);
1287 } else if (features->device_type == BTN_TOOL_PEN) {
1288 __set_bit(BTN_TOOL_RUBBER, input_dev->keybit);
1289 __set_bit(BTN_TOOL_PEN, input_dev->keybit);
1290 __set_bit(BTN_STYLUS, input_dev->keybit);
1291 __set_bit(BTN_STYLUS2, input_dev->keybit);
1292 }
1293 break;
1081 } 1294 }
1082} 1295}
1083 1296
@@ -1215,6 +1428,14 @@ static const struct wacom_features wacom_features_0xE3 =
1215 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG }; 1428 { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255, 0, TABLETPC2FG };
1216static const struct wacom_features wacom_features_0x47 = 1429static const struct wacom_features wacom_features_0x47 =
1217 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS }; 1430 { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023, 31, INTUOS };
1431static struct wacom_features wacom_features_0xD0 =
1432 { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1433static struct wacom_features wacom_features_0xD1 =
1434 { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1435static struct wacom_features wacom_features_0xD2 =
1436 { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023, 63, BAMBOO_PT };
1437static struct wacom_features wacom_features_0xD3 =
1438 { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 1023, 63, BAMBOO_PT };
1218 1439
1219#define USB_DEVICE_WACOM(prod) \ 1440#define USB_DEVICE_WACOM(prod) \
1220 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \ 1441 USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
@@ -1279,6 +1500,10 @@ const struct usb_device_id wacom_ids[] = {
1279 { USB_DEVICE_WACOM(0xC6) }, 1500 { USB_DEVICE_WACOM(0xC6) },
1280 { USB_DEVICE_WACOM(0xC7) }, 1501 { USB_DEVICE_WACOM(0xC7) },
1281 { USB_DEVICE_WACOM(0xCE) }, 1502 { USB_DEVICE_WACOM(0xCE) },
1503 { USB_DEVICE_WACOM(0xD0) },
1504 { USB_DEVICE_WACOM(0xD1) },
1505 { USB_DEVICE_WACOM(0xD2) },
1506 { USB_DEVICE_WACOM(0xD3) },
1282 { USB_DEVICE_WACOM(0xF0) }, 1507 { USB_DEVICE_WACOM(0xF0) },
1283 { USB_DEVICE_WACOM(0xCC) }, 1508 { USB_DEVICE_WACOM(0xCC) },
1284 { USB_DEVICE_WACOM(0x90) }, 1509 { USB_DEVICE_WACOM(0x90) },