aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet/wacom_sys.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/tablet/wacom_sys.c')
-rw-r--r--drivers/input/tablet/wacom_sys.c87
1 files changed, 58 insertions, 29 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index b35876ee6908..449c0a46dbac 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -120,14 +120,16 @@ static int wacom_open(struct input_dev *dev)
120 120
121out: 121out:
122 mutex_unlock(&wacom->lock); 122 mutex_unlock(&wacom->lock);
123 if (retval) 123 usb_autopm_put_interface(wacom->intf);
124 usb_autopm_put_interface(wacom->intf);
125 return retval; 124 return retval;
126} 125}
127 126
128static void wacom_close(struct input_dev *dev) 127static void wacom_close(struct input_dev *dev)
129{ 128{
130 struct wacom *wacom = input_get_drvdata(dev); 129 struct wacom *wacom = input_get_drvdata(dev);
130 int autopm_error;
131
132 autopm_error = usb_autopm_get_interface(wacom->intf);
131 133
132 mutex_lock(&wacom->lock); 134 mutex_lock(&wacom->lock);
133 usb_kill_urb(wacom->irq); 135 usb_kill_urb(wacom->irq);
@@ -135,7 +137,8 @@ static void wacom_close(struct input_dev *dev)
135 wacom->intf->needs_remote_wakeup = 0; 137 wacom->intf->needs_remote_wakeup = 0;
136 mutex_unlock(&wacom->lock); 138 mutex_unlock(&wacom->lock);
137 139
138 usb_autopm_put_interface(wacom->intf); 140 if (!autopm_error)
141 usb_autopm_put_interface(wacom->intf);
139} 142}
140 143
141static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc, 144static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hid_desc,
@@ -190,23 +193,36 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
190 case HID_USAGE_X: 193 case HID_USAGE_X:
191 if (usage == WCM_DESKTOP) { 194 if (usage == WCM_DESKTOP) {
192 if (finger) { 195 if (finger) {
193 features->device_type = BTN_TOOL_DOUBLETAP; 196 features->device_type = BTN_TOOL_FINGER;
194 if (features->type == TABLETPC2FG) { 197 if (features->type == TABLETPC2FG) {
195 /* need to reset back */ 198 /* need to reset back */
196 features->pktlen = WACOM_PKGLEN_TPC2FG; 199 features->pktlen = WACOM_PKGLEN_TPC2FG;
197 features->device_type = BTN_TOOL_TRIPLETAP; 200 features->device_type = BTN_TOOL_DOUBLETAP;
201 }
202 if (features->type == BAMBOO_PT) {
203 /* need to reset back */
204 features->pktlen = WACOM_PKGLEN_BBTOUCH;
205 features->device_type = BTN_TOOL_DOUBLETAP;
206 features->x_phy =
207 get_unaligned_le16(&report[i + 5]);
208 features->x_max =
209 get_unaligned_le16(&report[i + 8]);
210 i += 15;
211 } else {
212 features->x_max =
213 get_unaligned_le16(&report[i + 3]);
214 features->x_phy =
215 get_unaligned_le16(&report[i + 6]);
216 features->unit = report[i + 9];
217 features->unitExpo = report[i + 11];
218 i += 12;
198 } 219 }
199 features->x_max =
200 get_unaligned_le16(&report[i + 3]);
201 features->x_phy =
202 get_unaligned_le16(&report[i + 6]);
203 features->unit = report[i + 9];
204 features->unitExpo = report[i + 11];
205 i += 12;
206 } else if (pen) { 220 } else if (pen) {
207 /* penabled only accepts exact bytes of data */ 221 /* penabled only accepts exact bytes of data */
208 if (features->type == TABLETPC2FG) 222 if (features->type == TABLETPC2FG)
209 features->pktlen = WACOM_PKGLEN_GRAPHIRE; 223 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
224 if (features->type == BAMBOO_PT)
225 features->pktlen = WACOM_PKGLEN_BBFUN;
210 features->device_type = BTN_TOOL_PEN; 226 features->device_type = BTN_TOOL_PEN;
211 features->x_max = 227 features->x_max =
212 get_unaligned_le16(&report[i + 3]); 228 get_unaligned_le16(&report[i + 3]);
@@ -225,16 +241,25 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
225 case HID_USAGE_Y: 241 case HID_USAGE_Y:
226 if (usage == WCM_DESKTOP) { 242 if (usage == WCM_DESKTOP) {
227 if (finger) { 243 if (finger) {
228 features->device_type = BTN_TOOL_DOUBLETAP; 244 features->device_type = BTN_TOOL_FINGER;
229 if (features->type == TABLETPC2FG) { 245 if (features->type == TABLETPC2FG) {
230 /* need to reset back */ 246 /* need to reset back */
231 features->pktlen = WACOM_PKGLEN_TPC2FG; 247 features->pktlen = WACOM_PKGLEN_TPC2FG;
232 features->device_type = BTN_TOOL_TRIPLETAP; 248 features->device_type = BTN_TOOL_DOUBLETAP;
233 features->y_max = 249 features->y_max =
234 get_unaligned_le16(&report[i + 3]); 250 get_unaligned_le16(&report[i + 3]);
235 features->y_phy = 251 features->y_phy =
236 get_unaligned_le16(&report[i + 6]); 252 get_unaligned_le16(&report[i + 6]);
237 i += 7; 253 i += 7;
254 } else if (features->type == BAMBOO_PT) {
255 /* need to reset back */
256 features->pktlen = WACOM_PKGLEN_BBTOUCH;
257 features->device_type = BTN_TOOL_DOUBLETAP;
258 features->y_phy =
259 get_unaligned_le16(&report[i + 3]);
260 features->y_max =
261 get_unaligned_le16(&report[i + 6]);
262 i += 12;
238 } else { 263 } else {
239 features->y_max = 264 features->y_max =
240 features->x_max; 265 features->x_max;
@@ -246,6 +271,8 @@ static int wacom_parse_hid(struct usb_interface *intf, struct hid_descriptor *hi
246 /* penabled only accepts exact bytes of data */ 271 /* penabled only accepts exact bytes of data */
247 if (features->type == TABLETPC2FG) 272 if (features->type == TABLETPC2FG)
248 features->pktlen = WACOM_PKGLEN_GRAPHIRE; 273 features->pktlen = WACOM_PKGLEN_GRAPHIRE;
274 if (features->type == BAMBOO_PT)
275 features->pktlen = WACOM_PKGLEN_BBFUN;
249 features->device_type = BTN_TOOL_PEN; 276 features->device_type = BTN_TOOL_PEN;
250 features->y_max = 277 features->y_max =
251 get_unaligned_le16(&report[i + 3]); 278 get_unaligned_le16(&report[i + 3]);
@@ -296,8 +323,9 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
296 if (!rep_data) 323 if (!rep_data)
297 return error; 324 return error;
298 325
299 /* ask to report tablet data if it is 2FGT or not a Tablet PC */ 326 /* ask to report tablet data if it is 2FGT Tablet PC or
300 if (features->device_type == BTN_TOOL_TRIPLETAP) { 327 * not a Tablet PC */
328 if (features->type == TABLETPC2FG) {
301 do { 329 do {
302 rep_data[0] = 3; 330 rep_data[0] = 3;
303 rep_data[1] = 4; 331 rep_data[1] = 4;
@@ -309,7 +337,7 @@ static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_feat
309 WAC_HID_FEATURE_REPORT, report_id, 337 WAC_HID_FEATURE_REPORT, report_id,
310 rep_data, 3); 338 rep_data, 3);
311 } while ((error < 0 || rep_data[1] != 4) && limit++ < 5); 339 } while ((error < 0 || rep_data[1] != 4) && limit++ < 5);
312 } else if (features->type != TABLETPC && features->type != TABLETPC2FG) { 340 } else if (features->type != TABLETPC) {
313 do { 341 do {
314 rep_data[0] = 2; 342 rep_data[0] = 2;
315 rep_data[1] = 2; 343 rep_data[1] = 2;
@@ -334,11 +362,16 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
334 struct usb_host_interface *interface = intf->cur_altsetting; 362 struct usb_host_interface *interface = intf->cur_altsetting;
335 struct hid_descriptor *hid_desc; 363 struct hid_descriptor *hid_desc;
336 364
337 /* default device to penabled */ 365 /* default features */
338 features->device_type = BTN_TOOL_PEN; 366 features->device_type = BTN_TOOL_PEN;
339 367 features->x_fuzz = 4;
340 /* only Tablet PCs need to retrieve the info */ 368 features->y_fuzz = 4;
341 if ((features->type != TABLETPC) && (features->type != TABLETPC2FG)) 369 features->pressure_fuzz = 0;
370 features->distance_fuzz = 0;
371
372 /* only Tablet PCs and Bamboo P&T need to retrieve the info */
373 if ((features->type != TABLETPC) && (features->type != TABLETPC2FG) &&
374 (features->type != BAMBOO_PT))
342 goto out; 375 goto out;
343 376
344 if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) { 377 if (usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc)) {
@@ -353,12 +386,6 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
353 if (error) 386 if (error)
354 goto out; 387 goto out;
355 388
356 /* touch device found but size is not defined. use default */
357 if (features->device_type == BTN_TOOL_DOUBLETAP && !features->x_max) {
358 features->x_max = 1023;
359 features->y_max = 1023;
360 }
361
362 out: 389 out:
363 return error; 390 return error;
364} 391}
@@ -492,11 +519,13 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
492 /* Retrieve the physical and logical size for OEM devices */ 519 /* Retrieve the physical and logical size for OEM devices */
493 error = wacom_retrieve_hid_descriptor(intf, features); 520 error = wacom_retrieve_hid_descriptor(intf, features);
494 if (error) 521 if (error)
495 goto fail2; 522 goto fail3;
523
524 wacom_setup_device_quirks(features);
496 525
497 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name)); 526 strlcpy(wacom_wac->name, features->name, sizeof(wacom_wac->name));
498 527
499 if (features->type == TABLETPC || features->type == TABLETPC2FG) { 528 if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
500 /* Append the device type to the name */ 529 /* Append the device type to the name */
501 strlcat(wacom_wac->name, 530 strlcat(wacom_wac->name,
502 features->device_type == BTN_TOOL_PEN ? 531 features->device_type == BTN_TOOL_PEN ?