aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/tablet/wacom_sys.c
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2014-07-24 15:52:00 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-07-25 21:53:49 -0400
commitf54bc61cf7236db84939ca8827ac89737d79ef24 (patch)
tree778ddf249c7ec981c1e325fb4457009a77ee6f5d /drivers/input/tablet/wacom_sys.c
parent008f4d9e3cd666c1c4f97b53c102a868a6041f64 (diff)
Input: wacom - include and use linux/hid.h
The current wacom code redefines constants that are already in linux/hid.h This patch includes the official implementation and use it accross the code. There is a conflict with HID_USAGE and others at the same level: - in the wacom.ko implementation, those are the #define regarding the value of the field in the report descriptor - in the hid.h, those are bitmask So add HDESC_ in their current definition. Also, the struct hid_descriptor slightly differs from the linux/hid.h point of view, so mark it as custom for this driver. Signed-off-by: Benjamin Tissoires <benjamin.tissoires@redhat.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com> Tested-by: Jason Gerecke <killertofu@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input/tablet/wacom_sys.c')
-rw-r--r--drivers/input/tablet/wacom_sys.c53
1 files changed, 22 insertions, 31 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index dd0dbc250c94..c34791e7f0b9 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -13,28 +13,19 @@
13 13
14#include "wacom_wac.h" 14#include "wacom_wac.h"
15#include "wacom.h" 15#include "wacom.h"
16#include <linux/hid.h>
16 17
17/* defines to get HID report descriptor */ 18/* defines to get HID report descriptor */
18#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01) 19#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
19#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02) 20#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
20#define HID_USAGE_UNDEFINED 0x00 21#define HID_HDESC_USAGE_UNDEFINED 0x00
21#define HID_USAGE_PAGE 0x05 22#define HID_HDESC_USAGE_PAGE 0x05
22#define HID_USAGE_PAGE_DIGITIZER 0x0d 23#define HID_HDESC_USAGE 0x09
23#define HID_USAGE_PAGE_DESKTOP 0x01 24#define HID_HDESC_COLLECTION 0xa1
24#define HID_USAGE 0x09 25#define HID_HDESC_COLLECTION_LOGICAL 0x02
25#define HID_USAGE_X ((HID_USAGE_PAGE_DESKTOP << 16) | 0x30) 26#define HID_HDESC_COLLECTION_END 0xc0
26#define HID_USAGE_Y ((HID_USAGE_PAGE_DESKTOP << 16) | 0x31) 27
27#define HID_USAGE_PRESSURE ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x30) 28struct wac_hid_descriptor {
28#define HID_USAGE_X_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3d)
29#define HID_USAGE_Y_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3e)
30#define HID_USAGE_FINGER ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x22)
31#define HID_USAGE_STYLUS ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x20)
32#define HID_USAGE_CONTACTMAX ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x55)
33#define HID_COLLECTION 0xa1
34#define HID_COLLECTION_LOGICAL 0x02
35#define HID_COLLECTION_END 0xc0
36
37struct hid_descriptor {
38 struct usb_descriptor_header header; 29 struct usb_descriptor_header header;
39 __le16 bcdHID; 30 __le16 bcdHID;
40 u8 bCountryCode; 31 u8 bCountryCode;
@@ -301,7 +292,7 @@ static void wacom_retrieve_report_data(struct usb_interface *intf,
301 * this after returning from this function. 292 * this after returning from this function.
302 */ 293 */
303static int wacom_parse_hid(struct usb_interface *intf, 294static int wacom_parse_hid(struct usb_interface *intf,
304 struct hid_descriptor *hid_desc, 295 struct wac_hid_descriptor *hid_desc,
305 struct wacom_features *features) 296 struct wacom_features *features)
306{ 297{
307 struct usb_device *dev = interface_to_usbdev(intf); 298 struct usb_device *dev = interface_to_usbdev(intf);
@@ -334,14 +325,14 @@ static int wacom_parse_hid(struct usb_interface *intf,
334 for (i = 0; i < hid_desc->wDescriptorLength; i++) { 325 for (i = 0; i < hid_desc->wDescriptorLength; i++) {
335 326
336 switch (report[i]) { 327 switch (report[i]) {
337 case HID_USAGE_PAGE: 328 case HID_HDESC_USAGE_PAGE:
338 page = report[i + 1]; 329 page = report[i + 1];
339 i++; 330 i++;
340 break; 331 break;
341 332
342 case HID_USAGE: 333 case HID_HDESC_USAGE:
343 switch (page << 16 | report[i + 1]) { 334 switch (page << 16 | report[i + 1]) {
344 case HID_USAGE_X: 335 case HID_GD_X:
345 if (finger) { 336 if (finger) {
346 features->device_type = BTN_TOOL_FINGER; 337 features->device_type = BTN_TOOL_FINGER;
347 /* touch device at least supports one touch point */ 338 /* touch device at least supports one touch point */
@@ -420,7 +411,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
420 } 411 }
421 break; 412 break;
422 413
423 case HID_USAGE_Y: 414 case HID_GD_Y:
424 if (finger) { 415 if (finger) {
425 switch (features->type) { 416 switch (features->type) {
426 case TABLETPC2FG: 417 case TABLETPC2FG:
@@ -472,7 +463,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
472 } 463 }
473 break; 464 break;
474 465
475 case HID_USAGE_FINGER: 466 case HID_DG_FINGER:
476 finger = 1; 467 finger = 1;
477 i++; 468 i++;
478 break; 469 break;
@@ -482,19 +473,19 @@ static int wacom_parse_hid(struct usb_interface *intf,
482 * X/Y values and some cases of invalid Digitizer X/Y 473 * X/Y values and some cases of invalid Digitizer X/Y
483 * values commonly reported. 474 * values commonly reported.
484 */ 475 */
485 case HID_USAGE_STYLUS: 476 case HID_DG_STYLUS:
486 pen = 1; 477 pen = 1;
487 i++; 478 i++;
488 break; 479 break;
489 480
490 case HID_USAGE_CONTACTMAX: 481 case HID_DG_CONTACTMAX:
491 /* leave touch_max as is if predefined */ 482 /* leave touch_max as is if predefined */
492 if (!features->touch_max) 483 if (!features->touch_max)
493 wacom_retrieve_report_data(intf, features); 484 wacom_retrieve_report_data(intf, features);
494 i++; 485 i++;
495 break; 486 break;
496 487
497 case HID_USAGE_PRESSURE: 488 case HID_DG_TIPPRESSURE:
498 if (pen) { 489 if (pen) {
499 features->pressure_max = 490 features->pressure_max =
500 get_unaligned_le16(&report[i + 3]); 491 get_unaligned_le16(&report[i + 3]);
@@ -504,15 +495,15 @@ static int wacom_parse_hid(struct usb_interface *intf,
504 } 495 }
505 break; 496 break;
506 497
507 case HID_COLLECTION_END: 498 case HID_HDESC_COLLECTION_END:
508 /* reset UsagePage and Finger */ 499 /* reset UsagePage and Finger */
509 finger = page = 0; 500 finger = page = 0;
510 break; 501 break;
511 502
512 case HID_COLLECTION: 503 case HID_HDESC_COLLECTION:
513 i++; 504 i++;
514 switch (report[i]) { 505 switch (report[i]) {
515 case HID_COLLECTION_LOGICAL: 506 case HID_HDESC_COLLECTION_LOGICAL:
516 i += wacom_parse_logical_collection(&report[i], 507 i += wacom_parse_logical_collection(&report[i],
517 features); 508 features);
518 break; 509 break;
@@ -585,7 +576,7 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
585{ 576{
586 int error = 0; 577 int error = 0;
587 struct usb_host_interface *interface = intf->cur_altsetting; 578 struct usb_host_interface *interface = intf->cur_altsetting;
588 struct hid_descriptor *hid_desc; 579 struct wac_hid_descriptor *hid_desc;
589 580
590 /* default features */ 581 /* default features */
591 features->device_type = BTN_TOOL_PEN; 582 features->device_type = BTN_TOOL_PEN;