Commit f54bc61c authored by Benjamin Tissoires's avatar Benjamin Tissoires Committed by Dmitry Torokhov

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: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: default avatarJason Gerecke <killertofu@gmail.com>
Tested-by: default avatarJason Gerecke <killertofu@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 008f4d9e
...@@ -13,28 +13,19 @@ ...@@ -13,28 +13,19 @@
#include "wacom_wac.h" #include "wacom_wac.h"
#include "wacom.h" #include "wacom.h"
#include <linux/hid.h>
/* defines to get HID report descriptor */ /* defines to get HID report descriptor */
#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01) #define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02) #define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
#define HID_USAGE_UNDEFINED 0x00 #define HID_HDESC_USAGE_UNDEFINED 0x00
#define HID_USAGE_PAGE 0x05 #define HID_HDESC_USAGE_PAGE 0x05
#define HID_USAGE_PAGE_DIGITIZER 0x0d #define HID_HDESC_USAGE 0x09
#define HID_USAGE_PAGE_DESKTOP 0x01 #define HID_HDESC_COLLECTION 0xa1
#define HID_USAGE 0x09 #define HID_HDESC_COLLECTION_LOGICAL 0x02
#define HID_USAGE_X ((HID_USAGE_PAGE_DESKTOP << 16) | 0x30) #define HID_HDESC_COLLECTION_END 0xc0
#define HID_USAGE_Y ((HID_USAGE_PAGE_DESKTOP << 16) | 0x31)
#define HID_USAGE_PRESSURE ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x30) struct wac_hid_descriptor {
#define HID_USAGE_X_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3d)
#define HID_USAGE_Y_TILT ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x3e)
#define HID_USAGE_FINGER ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x22)
#define HID_USAGE_STYLUS ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x20)
#define HID_USAGE_CONTACTMAX ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x55)
#define HID_COLLECTION 0xa1
#define HID_COLLECTION_LOGICAL 0x02
#define HID_COLLECTION_END 0xc0
struct hid_descriptor {
struct usb_descriptor_header header; struct usb_descriptor_header header;
__le16 bcdHID; __le16 bcdHID;
u8 bCountryCode; u8 bCountryCode;
...@@ -301,7 +292,7 @@ static void wacom_retrieve_report_data(struct usb_interface *intf, ...@@ -301,7 +292,7 @@ static void wacom_retrieve_report_data(struct usb_interface *intf,
* this after returning from this function. * this after returning from this function.
*/ */
static int wacom_parse_hid(struct usb_interface *intf, static int wacom_parse_hid(struct usb_interface *intf,
struct hid_descriptor *hid_desc, struct wac_hid_descriptor *hid_desc,
struct wacom_features *features) struct wacom_features *features)
{ {
struct usb_device *dev = interface_to_usbdev(intf); struct usb_device *dev = interface_to_usbdev(intf);
...@@ -334,14 +325,14 @@ static int wacom_parse_hid(struct usb_interface *intf, ...@@ -334,14 +325,14 @@ static int wacom_parse_hid(struct usb_interface *intf,
for (i = 0; i < hid_desc->wDescriptorLength; i++) { for (i = 0; i < hid_desc->wDescriptorLength; i++) {
switch (report[i]) { switch (report[i]) {
case HID_USAGE_PAGE: case HID_HDESC_USAGE_PAGE:
page = report[i + 1]; page = report[i + 1];
i++; i++;
break; break;
case HID_USAGE: case HID_HDESC_USAGE:
switch (page << 16 | report[i + 1]) { switch (page << 16 | report[i + 1]) {
case HID_USAGE_X: case HID_GD_X:
if (finger) { if (finger) {
features->device_type = BTN_TOOL_FINGER; features->device_type = BTN_TOOL_FINGER;
/* touch device at least supports one touch point */ /* touch device at least supports one touch point */
...@@ -420,7 +411,7 @@ static int wacom_parse_hid(struct usb_interface *intf, ...@@ -420,7 +411,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
} }
break; break;
case HID_USAGE_Y: case HID_GD_Y:
if (finger) { if (finger) {
switch (features->type) { switch (features->type) {
case TABLETPC2FG: case TABLETPC2FG:
...@@ -472,7 +463,7 @@ static int wacom_parse_hid(struct usb_interface *intf, ...@@ -472,7 +463,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
} }
break; break;
case HID_USAGE_FINGER: case HID_DG_FINGER:
finger = 1; finger = 1;
i++; i++;
break; break;
...@@ -482,19 +473,19 @@ static int wacom_parse_hid(struct usb_interface *intf, ...@@ -482,19 +473,19 @@ static int wacom_parse_hid(struct usb_interface *intf,
* X/Y values and some cases of invalid Digitizer X/Y * X/Y values and some cases of invalid Digitizer X/Y
* values commonly reported. * values commonly reported.
*/ */
case HID_USAGE_STYLUS: case HID_DG_STYLUS:
pen = 1; pen = 1;
i++; i++;
break; break;
case HID_USAGE_CONTACTMAX: case HID_DG_CONTACTMAX:
/* leave touch_max as is if predefined */ /* leave touch_max as is if predefined */
if (!features->touch_max) if (!features->touch_max)
wacom_retrieve_report_data(intf, features); wacom_retrieve_report_data(intf, features);
i++; i++;
break; break;
case HID_USAGE_PRESSURE: case HID_DG_TIPPRESSURE:
if (pen) { if (pen) {
features->pressure_max = features->pressure_max =
get_unaligned_le16(&report[i + 3]); get_unaligned_le16(&report[i + 3]);
...@@ -504,15 +495,15 @@ static int wacom_parse_hid(struct usb_interface *intf, ...@@ -504,15 +495,15 @@ static int wacom_parse_hid(struct usb_interface *intf,
} }
break; break;
case HID_COLLECTION_END: case HID_HDESC_COLLECTION_END:
/* reset UsagePage and Finger */ /* reset UsagePage and Finger */
finger = page = 0; finger = page = 0;
break; break;
case HID_COLLECTION: case HID_HDESC_COLLECTION:
i++; i++;
switch (report[i]) { switch (report[i]) {
case HID_COLLECTION_LOGICAL: case HID_HDESC_COLLECTION_LOGICAL:
i += wacom_parse_logical_collection(&report[i], i += wacom_parse_logical_collection(&report[i],
features); features);
break; break;
...@@ -585,7 +576,7 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf, ...@@ -585,7 +576,7 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
{ {
int error = 0; int error = 0;
struct usb_host_interface *interface = intf->cur_altsetting; struct usb_host_interface *interface = intf->cur_altsetting;
struct hid_descriptor *hid_desc; struct wac_hid_descriptor *hid_desc;
/* default features */ /* default features */
features->device_type = BTN_TOOL_PEN; features->device_type = BTN_TOOL_PEN;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment