aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Gerecke <killertofu@gmail.com>2015-06-15 21:01:45 -0400
committerJiri Kosina <jkosina@suse.cz>2015-06-18 04:42:40 -0400
commit2a6cdbdd4cc0da0b0190b9a43648dff7b44adc0a (patch)
treecd511d93cf8a2ecfb09f527a930376de7ab2743d
parent2636a3f2d1421e3e629dfc96489c23727bab17d7 (diff)
HID: wacom: Introduce new 'touch_input' device
Instead of having a single 'input_dev' device that will take either pen or touch data depending on the type of the device, create seperate devices devices for each. By splitting things like this, we can support devices (e.g. the I2C "AES" sensors in some newer tablet PCs) that send both pen and touch reports from a single endpoint. Signed-off-by: Jason Gerecke <jason.gerecke@wacom.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
-rw-r--r--drivers/hid/wacom_sys.c116
-rw-r--r--drivers/hid/wacom_wac.c115
-rw-r--r--drivers/hid/wacom_wac.h9
3 files changed, 139 insertions, 101 deletions
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c
index ca15c7f59dc7..4c0ffca97bef 100644
--- a/drivers/hid/wacom_sys.c
+++ b/drivers/hid/wacom_sys.c
@@ -253,7 +253,7 @@ static void wacom_post_parse_hid(struct hid_device *hdev,
253 if (features->type == HID_GENERIC) { 253 if (features->type == HID_GENERIC) {
254 /* Any last-minute generic device setup */ 254 /* Any last-minute generic device setup */
255 if (features->touch_max > 1) { 255 if (features->touch_max > 1) {
256 input_mt_init_slots(wacom_wac->input, wacom_wac->features.touch_max, 256 input_mt_init_slots(wacom_wac->touch_input, wacom_wac->features.touch_max,
257 INPUT_MT_DIRECT); 257 INPUT_MT_DIRECT);
258 } 258 }
259 } 259 }
@@ -1130,7 +1130,7 @@ static struct input_dev *wacom_allocate_input(struct wacom *wacom)
1130 if (!input_dev) 1130 if (!input_dev)
1131 return NULL; 1131 return NULL;
1132 1132
1133 input_dev->name = wacom_wac->name; 1133 input_dev->name = wacom_wac->pen_name;
1134 input_dev->phys = hdev->phys; 1134 input_dev->phys = hdev->phys;
1135 input_dev->dev.parent = &hdev->dev; 1135 input_dev->dev.parent = &hdev->dev;
1136 input_dev->open = wacom_open; 1136 input_dev->open = wacom_open;
@@ -1149,27 +1149,33 @@ static void wacom_free_inputs(struct wacom *wacom)
1149{ 1149{
1150 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1150 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1151 1151
1152 if (wacom_wac->input) 1152 if (wacom_wac->pen_input)
1153 input_free_device(wacom_wac->input); 1153 input_free_device(wacom_wac->pen_input);
1154 if (wacom_wac->touch_input)
1155 input_free_device(wacom_wac->touch_input);
1154 if (wacom_wac->pad_input) 1156 if (wacom_wac->pad_input)
1155 input_free_device(wacom_wac->pad_input); 1157 input_free_device(wacom_wac->pad_input);
1156 wacom_wac->input = NULL; 1158 wacom_wac->pen_input = NULL;
1159 wacom_wac->touch_input = NULL;
1157 wacom_wac->pad_input = NULL; 1160 wacom_wac->pad_input = NULL;
1158} 1161}
1159 1162
1160static int wacom_allocate_inputs(struct wacom *wacom) 1163static int wacom_allocate_inputs(struct wacom *wacom)
1161{ 1164{
1162 struct input_dev *input_dev, *pad_input_dev; 1165 struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
1163 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1166 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1164 1167
1165 input_dev = wacom_allocate_input(wacom); 1168 pen_input_dev = wacom_allocate_input(wacom);
1169 touch_input_dev = wacom_allocate_input(wacom);
1166 pad_input_dev = wacom_allocate_input(wacom); 1170 pad_input_dev = wacom_allocate_input(wacom);
1167 if (!input_dev || !pad_input_dev) { 1171 if (!pen_input_dev || !touch_input_dev || !pad_input_dev) {
1168 wacom_free_inputs(wacom); 1172 wacom_free_inputs(wacom);
1169 return -ENOMEM; 1173 return -ENOMEM;
1170 } 1174 }
1171 1175
1172 wacom_wac->input = input_dev; 1176 wacom_wac->pen_input = pen_input_dev;
1177 wacom_wac->touch_input = touch_input_dev;
1178 wacom_wac->touch_input->name = wacom_wac->touch_name;
1173 wacom_wac->pad_input = pad_input_dev; 1179 wacom_wac->pad_input = pad_input_dev;
1174 wacom_wac->pad_input->name = wacom_wac->pad_name; 1180 wacom_wac->pad_input->name = wacom_wac->pad_name;
1175 1181
@@ -1178,11 +1184,17 @@ static int wacom_allocate_inputs(struct wacom *wacom)
1178 1184
1179static void wacom_clean_inputs(struct wacom *wacom) 1185static void wacom_clean_inputs(struct wacom *wacom)
1180{ 1186{
1181 if (wacom->wacom_wac.input) { 1187 if (wacom->wacom_wac.pen_input) {
1182 if (wacom->wacom_wac.input_registered) 1188 if (wacom->wacom_wac.pen_registered)
1183 input_unregister_device(wacom->wacom_wac.input); 1189 input_unregister_device(wacom->wacom_wac.pen_input);
1184 else 1190 else
1185 input_free_device(wacom->wacom_wac.input); 1191 input_free_device(wacom->wacom_wac.pen_input);
1192 }
1193 if (wacom->wacom_wac.touch_input) {
1194 if (wacom->wacom_wac.touch_registered)
1195 input_unregister_device(wacom->wacom_wac.touch_input);
1196 else
1197 input_free_device(wacom->wacom_wac.touch_input);
1186 } 1198 }
1187 if (wacom->wacom_wac.pad_input) { 1199 if (wacom->wacom_wac.pad_input) {
1188 if (wacom->wacom_wac.pad_registered) 1200 if (wacom->wacom_wac.pad_registered)
@@ -1190,33 +1202,49 @@ static void wacom_clean_inputs(struct wacom *wacom)
1190 else 1202 else
1191 input_free_device(wacom->wacom_wac.pad_input); 1203 input_free_device(wacom->wacom_wac.pad_input);
1192 } 1204 }
1193 wacom->wacom_wac.input = NULL; 1205 wacom->wacom_wac.pen_input = NULL;
1206 wacom->wacom_wac.touch_input = NULL;
1194 wacom->wacom_wac.pad_input = NULL; 1207 wacom->wacom_wac.pad_input = NULL;
1195 wacom_destroy_leds(wacom); 1208 wacom_destroy_leds(wacom);
1196} 1209}
1197 1210
1198static int wacom_register_inputs(struct wacom *wacom) 1211static int wacom_register_inputs(struct wacom *wacom)
1199{ 1212{
1200 struct input_dev *input_dev, *pad_input_dev; 1213 struct input_dev *pen_input_dev, *touch_input_dev, *pad_input_dev;
1201 struct wacom_wac *wacom_wac = &(wacom->wacom_wac); 1214 struct wacom_wac *wacom_wac = &(wacom->wacom_wac);
1202 struct wacom_features *features = &wacom_wac->features;
1203 int error = 0; 1215 int error = 0;
1204 1216
1205 input_dev = wacom_wac->input; 1217 pen_input_dev = wacom_wac->pen_input;
1218 touch_input_dev = wacom_wac->touch_input;
1206 pad_input_dev = wacom_wac->pad_input; 1219 pad_input_dev = wacom_wac->pad_input;
1207 1220
1208 if (!input_dev || !pad_input_dev) 1221 if (!pen_input_dev || !touch_input_dev || !pad_input_dev)
1209 return -EINVAL; 1222 return -EINVAL;
1210 1223
1211 if (features->device_type & WACOM_DEVICETYPE_PEN) 1224 error = wacom_setup_pen_input_capabilities(pen_input_dev, wacom_wac);
1212 error = wacom_setup_pen_input_capabilities(input_dev, wacom_wac); 1225 if (error) {
1213 if (!error && features->device_type & WACOM_DEVICETYPE_TOUCH) 1226 /* no pen in use on this interface */
1214 error = wacom_setup_touch_input_capabilities(input_dev, wacom_wac); 1227 input_free_device(pen_input_dev);
1215 if (!error) { 1228 wacom_wac->pen_input = NULL;
1216 error = input_register_device(input_dev); 1229 pen_input_dev = NULL;
1230 } else {
1231 error = input_register_device(pen_input_dev);
1232 if (error)
1233 goto fail_register_pen_input;
1234 wacom_wac->pen_registered = true;
1235 }
1236
1237 error = wacom_setup_touch_input_capabilities(touch_input_dev, wacom_wac);
1238 if (error) {
1239 /* no touch in use on this interface */
1240 input_free_device(touch_input_dev);
1241 wacom_wac->touch_input = NULL;
1242 touch_input_dev = NULL;
1243 } else {
1244 error = input_register_device(touch_input_dev);
1217 if (error) 1245 if (error)
1218 return error; 1246 goto fail_register_touch_input;
1219 wacom_wac->input_registered = true; 1247 wacom_wac->touch_registered = true;
1220 } 1248 }
1221 1249
1222 error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac); 1250 error = wacom_setup_pad_input_capabilities(pad_input_dev, wacom_wac);
@@ -1243,9 +1271,14 @@ fail_leds:
1243 pad_input_dev = NULL; 1271 pad_input_dev = NULL;
1244 wacom_wac->pad_registered = false; 1272 wacom_wac->pad_registered = false;
1245fail_register_pad_input: 1273fail_register_pad_input:
1246 input_unregister_device(input_dev); 1274 input_unregister_device(touch_input_dev);
1247 wacom_wac->input = NULL; 1275 wacom_wac->touch_input = NULL;
1248 wacom_wac->input_registered = false; 1276 wacom_wac->touch_registered = false;
1277fail_register_touch_input:
1278 input_unregister_device(pen_input_dev);
1279 wacom_wac->pen_input = NULL;
1280 wacom_wac->pen_registered = false;
1281fail_register_pen_input:
1249 return error; 1282 return error;
1250} 1283}
1251 1284
@@ -1306,7 +1339,7 @@ static void wacom_wireless_work(struct work_struct *work)
1306 if (wacom_wac1->features.type != INTUOSHT && 1339 if (wacom_wac1->features.type != INTUOSHT &&
1307 wacom_wac1->features.type != BAMBOO_PT) 1340 wacom_wac1->features.type != BAMBOO_PT)
1308 wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD; 1341 wacom_wac1->features.device_type |= WACOM_DEVICETYPE_PAD;
1309 snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen", 1342 snprintf(wacom_wac1->pen_name, WACOM_NAME_MAX, "%s (WL) Pen",
1310 wacom_wac1->features.name); 1343 wacom_wac1->features.name);
1311 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad", 1344 snprintf(wacom_wac1->pad_name, WACOM_NAME_MAX, "%s (WL) Pad",
1312 wacom_wac1->features.name); 1345 wacom_wac1->features.name);
@@ -1325,7 +1358,7 @@ static void wacom_wireless_work(struct work_struct *work)
1325 *((struct wacom_features *)id->driver_data); 1358 *((struct wacom_features *)id->driver_data);
1326 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3; 1359 wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
1327 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096; 1360 wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
1328 snprintf(wacom_wac2->name, WACOM_NAME_MAX, 1361 snprintf(wacom_wac2->touch_name, WACOM_NAME_MAX,
1329 "%s (WL) Finger",wacom_wac2->features.name); 1362 "%s (WL) Finger",wacom_wac2->features.name);
1330 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX, 1363 snprintf(wacom_wac2->pad_name, WACOM_NAME_MAX,
1331 "%s (WL) Pad",wacom_wac2->features.name); 1364 "%s (WL) Pad",wacom_wac2->features.name);
@@ -1342,7 +1375,7 @@ static void wacom_wireless_work(struct work_struct *work)
1342 1375
1343 if (wacom_wac1->features.type == INTUOSHT && 1376 if (wacom_wac1->features.type == INTUOSHT &&
1344 wacom_wac1->features.touch_max) 1377 wacom_wac1->features.touch_max)
1345 wacom_wac->shared->touch_input = wacom_wac2->input; 1378 wacom_wac->shared->touch_input = wacom_wac2->touch_input;
1346 } 1379 }
1347 1380
1348 error = wacom_initialize_battery(wacom); 1381 error = wacom_initialize_battery(wacom);
@@ -1457,21 +1490,12 @@ static void wacom_update_name(struct wacom *wacom)
1457 } 1490 }
1458 1491
1459 /* Append the device type to the name */ 1492 /* Append the device type to the name */
1493 snprintf(wacom_wac->pen_name, sizeof(wacom_wac->pen_name),
1494 "%s Pen", name);
1495 snprintf(wacom_wac->touch_name, sizeof(wacom_wac->touch_name),
1496 "%s Finger", name);
1460 snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name), 1497 snprintf(wacom_wac->pad_name, sizeof(wacom_wac->pad_name),
1461 "%s Pad", name); 1498 "%s Pad", name);
1462
1463 if (features->device_type & WACOM_DEVICETYPE_PEN) {
1464 snprintf(wacom_wac->name, sizeof(wacom_wac->name),
1465 "%s Pen", name);
1466 }
1467 else if (features->device_type & WACOM_DEVICETYPE_TOUCH) {
1468 snprintf(wacom_wac->name, sizeof(wacom_wac->name),
1469 "%s Finger", name);
1470 }
1471 else if (features->device_type & WACOM_DEVICETYPE_PAD) {
1472 snprintf(wacom_wac->name, sizeof(wacom_wac->name),
1473 "%s Pad", name);
1474 }
1475} 1499}
1476 1500
1477static int wacom_probe(struct hid_device *hdev, 1501static int wacom_probe(struct hid_device *hdev,
@@ -1615,7 +1639,7 @@ static int wacom_probe(struct hid_device *hdev,
1615 1639
1616 if (wacom_wac->features.type == INTUOSHT && 1640 if (wacom_wac->features.type == INTUOSHT &&
1617 wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) { 1641 wacom_wac->features.device_type & WACOM_DEVICETYPE_TOUCH) {
1618 wacom_wac->shared->touch_input = wacom_wac->input; 1642 wacom_wac->shared->touch_input = wacom_wac->touch_input;
1619 } 1643 }
1620 1644
1621 return 0; 1645 return 0;
diff --git a/drivers/hid/wacom_wac.c b/drivers/hid/wacom_wac.c
index b80a67a860b4..d811e878a105 100644
--- a/drivers/hid/wacom_wac.c
+++ b/drivers/hid/wacom_wac.c
@@ -69,7 +69,7 @@ static void wacom_notify_battery(struct wacom_wac *wacom_wac,
69static int wacom_penpartner_irq(struct wacom_wac *wacom) 69static int wacom_penpartner_irq(struct wacom_wac *wacom)
70{ 70{
71 unsigned char *data = wacom->data; 71 unsigned char *data = wacom->data;
72 struct input_dev *input = wacom->input; 72 struct input_dev *input = wacom->pen_input;
73 73
74 switch (data[0]) { 74 switch (data[0]) {
75 case 1: 75 case 1:
@@ -114,7 +114,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
114{ 114{
115 struct wacom_features *features = &wacom->features; 115 struct wacom_features *features = &wacom->features;
116 unsigned char *data = wacom->data; 116 unsigned char *data = wacom->data;
117 struct input_dev *input = wacom->input; 117 struct input_dev *input = wacom->pen_input;
118 int prox, pressure; 118 int prox, pressure;
119 119
120 if (data[0] != WACOM_REPORT_PENABLED) { 120 if (data[0] != WACOM_REPORT_PENABLED) {
@@ -186,7 +186,7 @@ static int wacom_pl_irq(struct wacom_wac *wacom)
186static int wacom_ptu_irq(struct wacom_wac *wacom) 186static int wacom_ptu_irq(struct wacom_wac *wacom)
187{ 187{
188 unsigned char *data = wacom->data; 188 unsigned char *data = wacom->data;
189 struct input_dev *input = wacom->input; 189 struct input_dev *input = wacom->pen_input;
190 190
191 if (data[0] != WACOM_REPORT_PENABLED) { 191 if (data[0] != WACOM_REPORT_PENABLED) {
192 dev_dbg(input->dev.parent, 192 dev_dbg(input->dev.parent,
@@ -215,7 +215,7 @@ static int wacom_ptu_irq(struct wacom_wac *wacom)
215static int wacom_dtu_irq(struct wacom_wac *wacom) 215static int wacom_dtu_irq(struct wacom_wac *wacom)
216{ 216{
217 unsigned char *data = wacom->data; 217 unsigned char *data = wacom->data;
218 struct input_dev *input = wacom->input; 218 struct input_dev *input = wacom->pen_input;
219 int prox = data[1] & 0x20; 219 int prox = data[1] & 0x20;
220 220
221 dev_dbg(input->dev.parent, 221 dev_dbg(input->dev.parent,
@@ -245,7 +245,7 @@ static int wacom_dtu_irq(struct wacom_wac *wacom)
245static int wacom_dtus_irq(struct wacom_wac *wacom) 245static int wacom_dtus_irq(struct wacom_wac *wacom)
246{ 246{
247 char *data = wacom->data; 247 char *data = wacom->data;
248 struct input_dev *input = wacom->input; 248 struct input_dev *input = wacom->pen_input;
249 unsigned short prox, pressure = 0; 249 unsigned short prox, pressure = 0;
250 250
251 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) { 251 if (data[0] != WACOM_REPORT_DTUS && data[0] != WACOM_REPORT_DTUSPAD) {
@@ -297,7 +297,7 @@ static int wacom_graphire_irq(struct wacom_wac *wacom)
297{ 297{
298 struct wacom_features *features = &wacom->features; 298 struct wacom_features *features = &wacom->features;
299 unsigned char *data = wacom->data; 299 unsigned char *data = wacom->data;
300 struct input_dev *input = wacom->input; 300 struct input_dev *input = wacom->pen_input;
301 struct input_dev *pad_input = wacom->pad_input; 301 struct input_dev *pad_input = wacom->pad_input;
302 int battery_capacity, ps_connected; 302 int battery_capacity, ps_connected;
303 int prox; 303 int prox;
@@ -464,7 +464,7 @@ static int wacom_intuos_inout(struct wacom_wac *wacom)
464{ 464{
465 struct wacom_features *features = &wacom->features; 465 struct wacom_features *features = &wacom->features;
466 unsigned char *data = wacom->data; 466 unsigned char *data = wacom->data;
467 struct input_dev *input = wacom->input; 467 struct input_dev *input = wacom->pen_input;
468 int idx = 0; 468 int idx = 0;
469 469
470 /* tool number */ 470 /* tool number */
@@ -649,7 +649,7 @@ static void wacom_intuos_general(struct wacom_wac *wacom)
649{ 649{
650 struct wacom_features *features = &wacom->features; 650 struct wacom_features *features = &wacom->features;
651 unsigned char *data = wacom->data; 651 unsigned char *data = wacom->data;
652 struct input_dev *input = wacom->input; 652 struct input_dev *input = wacom->pen_input;
653 unsigned int t; 653 unsigned int t;
654 654
655 /* general pen packet */ 655 /* general pen packet */
@@ -681,7 +681,7 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
681{ 681{
682 struct wacom_features *features = &wacom->features; 682 struct wacom_features *features = &wacom->features;
683 unsigned char *data = wacom->data; 683 unsigned char *data = wacom->data;
684 struct input_dev *input = wacom->input; 684 struct input_dev *input = wacom->pen_input;
685 unsigned int t; 685 unsigned int t;
686 int idx = 0, result; 686 int idx = 0, result;
687 687
@@ -1025,7 +1025,7 @@ static void wacom_intuos_bt_process_data(struct wacom_wac *wacom,
1025 memcpy(wacom->data, data, 10); 1025 memcpy(wacom->data, data, 10);
1026 wacom_intuos_irq(wacom); 1026 wacom_intuos_irq(wacom);
1027 1027
1028 input_sync(wacom->input); 1028 input_sync(wacom->pen_input);
1029 if (wacom->pad_input) 1029 if (wacom->pad_input)
1030 input_sync(wacom->pad_input); 1030 input_sync(wacom->pad_input);
1031} 1031}
@@ -1057,7 +1057,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1057 ps_connected); 1057 ps_connected);
1058 break; 1058 break;
1059 default: 1059 default:
1060 dev_dbg(wacom->input->dev.parent, 1060 dev_dbg(wacom->pen_input->dev.parent,
1061 "Unknown report: %d,%d size:%zu\n", 1061 "Unknown report: %d,%d size:%zu\n",
1062 data[0], data[1], len); 1062 data[0], data[1], len);
1063 return 0; 1063 return 0;
@@ -1067,7 +1067,7 @@ static int wacom_intuos_bt_irq(struct wacom_wac *wacom, size_t len)
1067 1067
1068static int wacom_wac_finger_count_touches(struct wacom_wac *wacom) 1068static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1069{ 1069{
1070 struct input_dev *input = wacom->input; 1070 struct input_dev *input = wacom->touch_input;
1071 unsigned touch_max = wacom->features.touch_max; 1071 unsigned touch_max = wacom->features.touch_max;
1072 int count = 0; 1072 int count = 0;
1073 int i; 1073 int i;
@@ -1088,7 +1088,7 @@ static int wacom_wac_finger_count_touches(struct wacom_wac *wacom)
1088 1088
1089static int wacom_24hdt_irq(struct wacom_wac *wacom) 1089static int wacom_24hdt_irq(struct wacom_wac *wacom)
1090{ 1090{
1091 struct input_dev *input = wacom->input; 1091 struct input_dev *input = wacom->touch_input;
1092 unsigned char *data = wacom->data; 1092 unsigned char *data = wacom->data;
1093 int i; 1093 int i;
1094 int current_num_contacts = data[61]; 1094 int current_num_contacts = data[61];
@@ -1156,7 +1156,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
1156 1156
1157static int wacom_mt_touch(struct wacom_wac *wacom) 1157static int wacom_mt_touch(struct wacom_wac *wacom)
1158{ 1158{
1159 struct input_dev *input = wacom->input; 1159 struct input_dev *input = wacom->touch_input;
1160 unsigned char *data = wacom->data; 1160 unsigned char *data = wacom->data;
1161 int i; 1161 int i;
1162 int current_num_contacts = data[2]; 1162 int current_num_contacts = data[2];
@@ -1207,7 +1207,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
1207 1207
1208static int wacom_tpc_mt_touch(struct wacom_wac *wacom) 1208static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1209{ 1209{
1210 struct input_dev *input = wacom->input; 1210 struct input_dev *input = wacom->touch_input;
1211 unsigned char *data = wacom->data; 1211 unsigned char *data = wacom->data;
1212 int i; 1212 int i;
1213 1213
@@ -1236,7 +1236,7 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
1236static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len) 1236static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1237{ 1237{
1238 unsigned char *data = wacom->data; 1238 unsigned char *data = wacom->data;
1239 struct input_dev *input = wacom->input; 1239 struct input_dev *input = wacom->touch_input;
1240 bool prox = !wacom->shared->stylus_in_proximity; 1240 bool prox = !wacom->shared->stylus_in_proximity;
1241 int x = 0, y = 0; 1241 int x = 0, y = 0;
1242 1242
@@ -1272,7 +1272,7 @@ static int wacom_tpc_single_touch(struct wacom_wac *wacom, size_t len)
1272static int wacom_tpc_pen(struct wacom_wac *wacom) 1272static int wacom_tpc_pen(struct wacom_wac *wacom)
1273{ 1273{
1274 unsigned char *data = wacom->data; 1274 unsigned char *data = wacom->data;
1275 struct input_dev *input = wacom->input; 1275 struct input_dev *input = wacom->pen_input;
1276 bool prox = data[1] & 0x20; 1276 bool prox = data[1] & 0x20;
1277 1277
1278 if (!wacom->shared->stylus_in_proximity) /* first in prox */ 1278 if (!wacom->shared->stylus_in_proximity) /* first in prox */
@@ -1301,8 +1301,12 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1301{ 1301{
1302 unsigned char *data = wacom->data; 1302 unsigned char *data = wacom->data;
1303 1303
1304 dev_dbg(wacom->input->dev.parent, 1304 if (wacom->pen_input)
1305 "%s: received report #%d\n", __func__, data[0]); 1305 dev_dbg(wacom->pen_input->dev.parent,
1306 "%s: received report #%d\n", __func__, data[0]);
1307 else if (wacom->touch_input)
1308 dev_dbg(wacom->touch_input->dev.parent,
1309 "%s: received report #%d\n", __func__, data[0]);
1306 1310
1307 switch (len) { 1311 switch (len) {
1308 case WACOM_PKGLEN_TPC1FG: 1312 case WACOM_PKGLEN_TPC1FG:
@@ -1334,11 +1338,9 @@ static int wacom_tpc_irq(struct wacom_wac *wacom, size_t len)
1334 return 0; 1338 return 0;
1335} 1339}
1336 1340
1337static void wacom_map_usage(struct wacom *wacom, struct hid_usage *usage, 1341static void wacom_map_usage(struct input_dev *input, struct hid_usage *usage,
1338 struct hid_field *field, __u8 type, __u16 code, int fuzz) 1342 struct hid_field *field, __u8 type, __u16 code, int fuzz)
1339{ 1343{
1340 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1341 struct input_dev *input = wacom_wac->input;
1342 int fmin = field->logical_minimum; 1344 int fmin = field->logical_minimum;
1343 int fmax = field->logical_maximum; 1345 int fmax = field->logical_maximum;
1344 1346
@@ -1366,36 +1368,38 @@ static void wacom_wac_pen_usage_mapping(struct hid_device *hdev,
1366 struct hid_field *field, struct hid_usage *usage) 1368 struct hid_field *field, struct hid_usage *usage)
1367{ 1369{
1368 struct wacom *wacom = hid_get_drvdata(hdev); 1370 struct wacom *wacom = hid_get_drvdata(hdev);
1371 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1372 struct input_dev *input = wacom_wac->pen_input;
1369 1373
1370 switch (usage->hid) { 1374 switch (usage->hid) {
1371 case HID_GD_X: 1375 case HID_GD_X:
1372 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4); 1376 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
1373 break; 1377 break;
1374 case HID_GD_Y: 1378 case HID_GD_Y:
1375 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4); 1379 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
1376 break; 1380 break;
1377 case HID_DG_TIPPRESSURE: 1381 case HID_DG_TIPPRESSURE:
1378 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_PRESSURE, 0); 1382 wacom_map_usage(input, usage, field, EV_ABS, ABS_PRESSURE, 0);
1379 break; 1383 break;
1380 case HID_DG_INRANGE: 1384 case HID_DG_INRANGE:
1381 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOOL_PEN, 0); 1385 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOOL_PEN, 0);
1382 break; 1386 break;
1383 case HID_DG_INVERT: 1387 case HID_DG_INVERT:
1384 wacom_map_usage(wacom, usage, field, EV_KEY, 1388 wacom_map_usage(input, usage, field, EV_KEY,
1385 BTN_TOOL_RUBBER, 0); 1389 BTN_TOOL_RUBBER, 0);
1386 break; 1390 break;
1387 case HID_DG_ERASER: 1391 case HID_DG_ERASER:
1388 case HID_DG_TIPSWITCH: 1392 case HID_DG_TIPSWITCH:
1389 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0); 1393 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
1390 break; 1394 break;
1391 case HID_DG_BARRELSWITCH: 1395 case HID_DG_BARRELSWITCH:
1392 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS, 0); 1396 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS, 0);
1393 break; 1397 break;
1394 case HID_DG_BARRELSWITCH2: 1398 case HID_DG_BARRELSWITCH2:
1395 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_STYLUS2, 0); 1399 wacom_map_usage(input, usage, field, EV_KEY, BTN_STYLUS2, 0);
1396 break; 1400 break;
1397 case HID_DG_TOOLSERIALNUMBER: 1401 case HID_DG_TOOLSERIALNUMBER:
1398 wacom_map_usage(wacom, usage, field, EV_MSC, MSC_SERIAL, 0); 1402 wacom_map_usage(input, usage, field, EV_MSC, MSC_SERIAL, 0);
1399 break; 1403 break;
1400 } 1404 }
1401} 1405}
@@ -1405,7 +1409,7 @@ static int wacom_wac_pen_event(struct hid_device *hdev, struct hid_field *field,
1405{ 1409{
1406 struct wacom *wacom = hid_get_drvdata(hdev); 1410 struct wacom *wacom = hid_get_drvdata(hdev);
1407 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1411 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1408 struct input_dev *input = wacom_wac->input; 1412 struct input_dev *input = wacom_wac->pen_input;
1409 1413
1410 /* checking which Tool / tip switch to send */ 1414 /* checking which Tool / tip switch to send */
1411 switch (usage->hid) { 1415 switch (usage->hid) {
@@ -1435,7 +1439,7 @@ static void wacom_wac_pen_report(struct hid_device *hdev,
1435{ 1439{
1436 struct wacom *wacom = hid_get_drvdata(hdev); 1440 struct wacom *wacom = hid_get_drvdata(hdev);
1437 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1441 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1438 struct input_dev *input = wacom_wac->input; 1442 struct input_dev *input = wacom_wac->pen_input;
1439 bool prox = wacom_wac->hid_data.inrange_state; 1443 bool prox = wacom_wac->hid_data.inrange_state;
1440 1444
1441 if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */ 1445 if (!wacom_wac->shared->stylus_in_proximity) /* first in prox */
@@ -1464,23 +1468,24 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
1464 struct wacom *wacom = hid_get_drvdata(hdev); 1468 struct wacom *wacom = hid_get_drvdata(hdev);
1465 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1469 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1466 struct wacom_features *features = &wacom_wac->features; 1470 struct wacom_features *features = &wacom_wac->features;
1471 struct input_dev *input = wacom_wac->touch_input;
1467 unsigned touch_max = wacom_wac->features.touch_max; 1472 unsigned touch_max = wacom_wac->features.touch_max;
1468 1473
1469 switch (usage->hid) { 1474 switch (usage->hid) {
1470 case HID_GD_X: 1475 case HID_GD_X:
1471 features->last_slot_field = usage->hid; 1476 features->last_slot_field = usage->hid;
1472 if (touch_max == 1) 1477 if (touch_max == 1)
1473 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_X, 4); 1478 wacom_map_usage(input, usage, field, EV_ABS, ABS_X, 4);
1474 else 1479 else
1475 wacom_map_usage(wacom, usage, field, EV_ABS, 1480 wacom_map_usage(input, usage, field, EV_ABS,
1476 ABS_MT_POSITION_X, 4); 1481 ABS_MT_POSITION_X, 4);
1477 break; 1482 break;
1478 case HID_GD_Y: 1483 case HID_GD_Y:
1479 features->last_slot_field = usage->hid; 1484 features->last_slot_field = usage->hid;
1480 if (touch_max == 1) 1485 if (touch_max == 1)
1481 wacom_map_usage(wacom, usage, field, EV_ABS, ABS_Y, 4); 1486 wacom_map_usage(input, usage, field, EV_ABS, ABS_Y, 4);
1482 else 1487 else
1483 wacom_map_usage(wacom, usage, field, EV_ABS, 1488 wacom_map_usage(input, usage, field, EV_ABS,
1484 ABS_MT_POSITION_Y, 4); 1489 ABS_MT_POSITION_Y, 4);
1485 break; 1490 break;
1486 case HID_DG_CONTACTID: 1491 case HID_DG_CONTACTID:
@@ -1494,7 +1499,7 @@ static void wacom_wac_finger_usage_mapping(struct hid_device *hdev,
1494 break; 1499 break;
1495 case HID_DG_TIPSWITCH: 1500 case HID_DG_TIPSWITCH:
1496 features->last_slot_field = usage->hid; 1501 features->last_slot_field = usage->hid;
1497 wacom_map_usage(wacom, usage, field, EV_KEY, BTN_TOUCH, 0); 1502 wacom_map_usage(input, usage, field, EV_KEY, BTN_TOUCH, 0);
1498 break; 1503 break;
1499 } 1504 }
1500} 1505}
@@ -1550,7 +1555,7 @@ static int wacom_wac_finger_event(struct hid_device *hdev,
1550 1555
1551 if (usage->usage_index + 1 == field->report_count) { 1556 if (usage->usage_index + 1 == field->report_count) {
1552 if (usage->hid == wacom_wac->features.last_slot_field) 1557 if (usage->hid == wacom_wac->features.last_slot_field)
1553 wacom_wac_finger_slot(wacom_wac, wacom_wac->input); 1558 wacom_wac_finger_slot(wacom_wac, wacom_wac->touch_input);
1554 } 1559 }
1555 1560
1556 return 0; 1561 return 0;
@@ -1561,7 +1566,7 @@ static void wacom_wac_finger_report(struct hid_device *hdev,
1561{ 1566{
1562 struct wacom *wacom = hid_get_drvdata(hdev); 1567 struct wacom *wacom = hid_get_drvdata(hdev);
1563 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1568 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1564 struct input_dev *input = wacom_wac->input; 1569 struct input_dev *input = wacom_wac->touch_input;
1565 unsigned touch_max = wacom_wac->features.touch_max; 1570 unsigned touch_max = wacom_wac->features.touch_max;
1566 1571
1567 if (touch_max > 1) 1572 if (touch_max > 1)
@@ -1578,10 +1583,10 @@ void wacom_wac_usage_mapping(struct hid_device *hdev,
1578{ 1583{
1579 struct wacom *wacom = hid_get_drvdata(hdev); 1584 struct wacom *wacom = hid_get_drvdata(hdev);
1580 struct wacom_wac *wacom_wac = &wacom->wacom_wac; 1585 struct wacom_wac *wacom_wac = &wacom->wacom_wac;
1581 struct input_dev *input = wacom_wac->input;
1582 1586
1583 /* currently, only direct devices have proper hid report descriptors */ 1587 /* currently, only direct devices have proper hid report descriptors */
1584 __set_bit(INPUT_PROP_DIRECT, input->propbit); 1588 __set_bit(INPUT_PROP_DIRECT, wacom_wac->pen_input->propbit);
1589 __set_bit(INPUT_PROP_DIRECT, wacom_wac->touch_input->propbit);
1585 1590
1586 if (WACOM_PEN_FIELD(field)) 1591 if (WACOM_PEN_FIELD(field))
1587 return wacom_wac_pen_usage_mapping(hdev, field, usage); 1592 return wacom_wac_pen_usage_mapping(hdev, field, usage);
@@ -1626,7 +1631,7 @@ void wacom_wac_report(struct hid_device *hdev, struct hid_report *report)
1626static int wacom_bpt_touch(struct wacom_wac *wacom) 1631static int wacom_bpt_touch(struct wacom_wac *wacom)
1627{ 1632{
1628 struct wacom_features *features = &wacom->features; 1633 struct wacom_features *features = &wacom->features;
1629 struct input_dev *input = wacom->input; 1634 struct input_dev *input = wacom->touch_input;
1630 struct input_dev *pad_input = wacom->pad_input; 1635 struct input_dev *pad_input = wacom->pad_input;
1631 unsigned char *data = wacom->data; 1636 unsigned char *data = wacom->data;
1632 int i; 1637 int i;
@@ -1674,7 +1679,7 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
1674static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data) 1679static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)
1675{ 1680{
1676 struct wacom_features *features = &wacom->features; 1681 struct wacom_features *features = &wacom->features;
1677 struct input_dev *input = wacom->input; 1682 struct input_dev *input = wacom->touch_input;
1678 bool touch = data[1] & 0x80; 1683 bool touch = data[1] & 0x80;
1679 int slot = input_mt_get_slot_by_key(input, data[0]); 1684 int slot = input_mt_get_slot_by_key(input, data[0]);
1680 1685
@@ -1732,7 +1737,6 @@ static void wacom_bpt3_button_msg(struct wacom_wac *wacom, unsigned char *data)
1732 1737
1733static int wacom_bpt3_touch(struct wacom_wac *wacom) 1738static int wacom_bpt3_touch(struct wacom_wac *wacom)
1734{ 1739{
1735 struct input_dev *input = wacom->input;
1736 unsigned char *data = wacom->data; 1740 unsigned char *data = wacom->data;
1737 int count = data[1] & 0x07; 1741 int count = data[1] & 0x07;
1738 int i; 1742 int i;
@@ -1751,8 +1755,12 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
1751 wacom_bpt3_button_msg(wacom, data + offset); 1755 wacom_bpt3_button_msg(wacom, data + offset);
1752 1756
1753 } 1757 }
1754 input_mt_sync_frame(input); 1758
1755 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom); 1759 /* only update the touch if we actually have a touchpad */
1760 if (wacom->touch_registered) {
1761 input_mt_sync_frame(wacom->touch_input);
1762 wacom->shared->touch_down = wacom_wac_finger_count_touches(wacom);
1763 }
1756 1764
1757 return 1; 1765 return 1;
1758} 1766}
@@ -1760,7 +1768,7 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
1760static int wacom_bpt_pen(struct wacom_wac *wacom) 1768static int wacom_bpt_pen(struct wacom_wac *wacom)
1761{ 1769{
1762 struct wacom_features *features = &wacom->features; 1770 struct wacom_features *features = &wacom->features;
1763 struct input_dev *input = wacom->input; 1771 struct input_dev *input = wacom->pen_input;
1764 unsigned char *data = wacom->data; 1772 unsigned char *data = wacom->data;
1765 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0; 1773 int prox = 0, x = 0, y = 0, p = 0, d = 0, pen = 0, btn1 = 0, btn2 = 0;
1766 1774
@@ -1869,7 +1877,7 @@ static void wacom_bamboo_pad_pen_event(struct wacom_wac *wacom,
1869static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom, 1877static int wacom_bamboo_pad_touch_event(struct wacom_wac *wacom,
1870 unsigned char *data) 1878 unsigned char *data)
1871{ 1879{
1872 struct input_dev *input = wacom->input; 1880 struct input_dev *input = wacom->touch_input;
1873 unsigned char *finger_data, prefix; 1881 unsigned char *finger_data, prefix;
1874 unsigned id; 1882 unsigned id;
1875 int x, y; 1883 int x, y;
@@ -2113,7 +2121,10 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
2113 } 2121 }
2114 2122
2115 if (sync) { 2123 if (sync) {
2116 input_sync(wacom_wac->input); 2124 if (wacom_wac->pen_input)
2125 input_sync(wacom_wac->pen_input);
2126 if (wacom_wac->touch_input)
2127 input_sync(wacom_wac->touch_input);
2117 if (wacom_wac->pad_input) 2128 if (wacom_wac->pad_input)
2118 input_sync(wacom_wac->pad_input); 2129 input_sync(wacom_wac->pad_input);
2119 } 2130 }
@@ -2121,7 +2132,7 @@ void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len)
2121 2132
2122static void wacom_setup_cintiq(struct wacom_wac *wacom_wac) 2133static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
2123{ 2134{
2124 struct input_dev *input_dev = wacom_wac->input; 2135 struct input_dev *input_dev = wacom_wac->pen_input;
2125 2136
2126 input_set_capability(input_dev, EV_MSC, MSC_SERIAL); 2137 input_set_capability(input_dev, EV_MSC, MSC_SERIAL);
2127 2138
@@ -2144,7 +2155,7 @@ static void wacom_setup_cintiq(struct wacom_wac *wacom_wac)
2144 2155
2145static void wacom_setup_intuos(struct wacom_wac *wacom_wac) 2156static void wacom_setup_intuos(struct wacom_wac *wacom_wac)
2146{ 2157{
2147 struct input_dev *input_dev = wacom_wac->input; 2158 struct input_dev *input_dev = wacom_wac->pen_input;
2148 2159
2149 input_set_capability(input_dev, EV_REL, REL_WHEEL); 2160 input_set_capability(input_dev, EV_REL, REL_WHEEL);
2150 2161
diff --git a/drivers/hid/wacom_wac.h b/drivers/hid/wacom_wac.h
index c873c9f5b562..2978c303909d 100644
--- a/drivers/hid/wacom_wac.h
+++ b/drivers/hid/wacom_wac.h
@@ -196,7 +196,8 @@ struct hid_data {
196}; 196};
197 197
198struct wacom_wac { 198struct wacom_wac {
199 char name[WACOM_NAME_MAX]; 199 char pen_name[WACOM_NAME_MAX];
200 char touch_name[WACOM_NAME_MAX];
200 char pad_name[WACOM_NAME_MAX]; 201 char pad_name[WACOM_NAME_MAX];
201 char bat_name[WACOM_NAME_MAX]; 202 char bat_name[WACOM_NAME_MAX];
202 char ac_name[WACOM_NAME_MAX]; 203 char ac_name[WACOM_NAME_MAX];
@@ -207,9 +208,11 @@ struct wacom_wac {
207 bool reporting_data; 208 bool reporting_data;
208 struct wacom_features features; 209 struct wacom_features features;
209 struct wacom_shared *shared; 210 struct wacom_shared *shared;
210 struct input_dev *input; 211 struct input_dev *pen_input;
212 struct input_dev *touch_input;
211 struct input_dev *pad_input; 213 struct input_dev *pad_input;
212 bool input_registered; 214 bool pen_registered;
215 bool touch_registered;
213 bool pad_registered; 216 bool pad_registered;
214 int pid; 217 int pid;
215 int battery_capacity; 218 int battery_capacity;