2014-06-30 21:26:42

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 00/15] Input - Wacom: switch from an USB to a HID driver

Hi guys,

this patch series is a cleanup for the Wacom USB driver.

I started working on this topic when I saw patches floating around which
implemented a report descriptor parser within the wacom.ko module.
However, we already have a nice HID subsystem which is more generic than the
HID implementation we can find in this USB driver.
Further details of the benefits (code reduction, regression tests) are hopefully
explained in the commit messages of the corresponding patches.

Also, I am working on a way to handle the new Wacom tablets in a more generic
way in the hid tree, so consider this patch series as a first step in this
direction.

This patch series transfers the wacom.ko driver from the input tree into the hid
tree. I did not made the corresponding move of the files in the series hoping
that we will find a way to achieve it if this step is validated.

IMO, the smoothest path would be that Jiri takes care of the wacom driver
in the input tree (and that we move into into the hid subfolder). This can be
achieve if the current pending wacom patches are applied in the hid tree too.

Another solution could be to keep the wacom changes in the input tree and put the
hid changes in the hid tree by using separate commits. Once 3.17 is out, we can
then change the module into the hid subfolder.

I wanted to send this patch series right now so we can figure out how we will
handle the transition.

I am pretty confident the patch series does not break any existing device
(except for the required user space changes which can be handled correctly if
we tackle them right now). The USB commands are executed in the same way,
and the protocol handling is also done in the same way.

Anyway, the net difference in lines of code (-307) should be enough to be of
interest.

Note: This patch series requires the current pending wacom patches to be applied.
I set up a tree with all the patch applied if anyone wants to give a try:
https://github.com/bentiss/linux/commits/hid-wacom-legacy-3.16-rc3

Cheers,
Benjamin

Benjamin Tissoires (15):
Input - wacom: include and use linux/hid.h
Input - wacom: switch from an USB driver to a HID driver
Input - wacom: use hid communication instead of plain usb
Input - wacom: use HID core to actually fetch the report descriptor
Input - wacom: compute the HID report size to get the actual packet
size
Input - wacom: install LED/OLED sysfs files in the HID device instead
of USB
Input - wacom: register the input devices on top of the HID one
Input - wacom: remove usb dependency for siblings devices
Input - wacom: register power device at the HID level
Input - wacom: use hid_info instead of plain dev_info
HID: uhid: add and set HID_TYPE_UHID for uhid devices
Input - wacom: use in-kernel HID parser
Input - wacom: use hidinput_calc_abs_res instead of duplicating its
code
Input - wacom: remove field pktlen declaration in the list of devices
Input - wacom: keep wacom_ids ordered

drivers/hid/hid-core.c | 15 +-
drivers/hid/hid-wacom.c | 2 +-
drivers/hid/uhid.c | 2 +
drivers/input/tablet/wacom.h | 7 +-
drivers/input/tablet/wacom_sys.c | 908 +++++++++++++--------------------------
drivers/input/tablet/wacom_wac.c | 647 ++++++++++++++--------------
drivers/input/tablet/wacom_wac.h | 10 +-
include/linux/hid.h | 4 +-
8 files changed, 644 insertions(+), 951 deletions(-)

--
2.0.0


2014-06-30 21:26:43

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 01/15] 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 <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 53 +++++++++++++++++-----------------------
1 file changed, 22 insertions(+), 31 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 598efd4..e0c1cb2 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -13,28 +13,19 @@

#include "wacom_wac.h"
#include "wacom.h"
+#include <linux/hid.h>

/* defines to get HID report descriptor */
#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
-#define HID_USAGE_UNDEFINED 0x00
-#define HID_USAGE_PAGE 0x05
-#define HID_USAGE_PAGE_DIGITIZER 0x0d
-#define HID_USAGE_PAGE_DESKTOP 0x01
-#define HID_USAGE 0x09
-#define HID_USAGE_X ((HID_USAGE_PAGE_DESKTOP << 16) | 0x30)
-#define HID_USAGE_Y ((HID_USAGE_PAGE_DESKTOP << 16) | 0x31)
-#define HID_USAGE_PRESSURE ((HID_USAGE_PAGE_DIGITIZER << 16) | 0x30)
-#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 {
+#define HID_HDESC_USAGE_UNDEFINED 0x00
+#define HID_HDESC_USAGE_PAGE 0x05
+#define HID_HDESC_USAGE 0x09
+#define HID_HDESC_COLLECTION 0xa1
+#define HID_HDESC_COLLECTION_LOGICAL 0x02
+#define HID_HDESC_COLLECTION_END 0xc0
+
+struct wac_hid_descriptor {
struct usb_descriptor_header header;
__le16 bcdHID;
u8 bCountryCode;
@@ -301,7 +292,7 @@ static void wacom_retrieve_report_data(struct usb_interface *intf,
* this after returning from this function.
*/
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 usb_device *dev = interface_to_usbdev(intf);
@@ -334,14 +325,14 @@ static int wacom_parse_hid(struct usb_interface *intf,
for (i = 0; i < hid_desc->wDescriptorLength; i++) {

switch (report[i]) {
- case HID_USAGE_PAGE:
+ case HID_HDESC_USAGE_PAGE:
page = report[i + 1];
i++;
break;

- case HID_USAGE:
+ case HID_HDESC_USAGE:
switch (page << 16 | report[i + 1]) {
- case HID_USAGE_X:
+ case HID_GD_X:
if (finger) {
features->device_type = BTN_TOOL_FINGER;
/* touch device at least supports one touch point */
@@ -420,7 +411,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
}
break;

- case HID_USAGE_Y:
+ case HID_GD_Y:
if (finger) {
switch (features->type) {
case TABLETPC2FG:
@@ -472,7 +463,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
}
break;

- case HID_USAGE_FINGER:
+ case HID_DG_FINGER:
finger = 1;
i++;
break;
@@ -482,19 +473,19 @@ static int wacom_parse_hid(struct usb_interface *intf,
* X/Y values and some cases of invalid Digitizer X/Y
* values commonly reported.
*/
- case HID_USAGE_STYLUS:
+ case HID_DG_STYLUS:
pen = 1;
i++;
break;

- case HID_USAGE_CONTACTMAX:
+ case HID_DG_CONTACTMAX:
/* leave touch_max as is if predefined */
if (!features->touch_max)
wacom_retrieve_report_data(intf, features);
i++;
break;

- case HID_USAGE_PRESSURE:
+ case HID_DG_TIPPRESSURE:
if (pen) {
features->pressure_max =
get_unaligned_le16(&report[i + 3]);
@@ -504,15 +495,15 @@ static int wacom_parse_hid(struct usb_interface *intf,
}
break;

- case HID_COLLECTION_END:
+ case HID_HDESC_COLLECTION_END:
/* reset UsagePage and Finger */
finger = page = 0;
break;

- case HID_COLLECTION:
+ case HID_HDESC_COLLECTION:
i++;
switch (report[i]) {
- case HID_COLLECTION_LOGICAL:
+ case HID_HDESC_COLLECTION_LOGICAL:
i += wacom_parse_logical_collection(&report[i],
features);
break;
@@ -585,7 +576,7 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
{
int error = 0;
struct usb_host_interface *interface = intf->cur_altsetting;
- struct hid_descriptor *hid_desc;
+ struct wac_hid_descriptor *hid_desc;

/* default features */
features->device_type = BTN_TOOL_PEN;
--
2.0.0

2014-06-30 21:26:50

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 02/15] Input - wacom: switch from an USB driver to a HID driver

All USB Wacom tablets are actually HID devices.
For historical reasons, they are handled as plain USB devices.
The current code makes more and more reference to the HID subsystem
like implementing its own HID report descriptor parser to handle new
devices.

>From the user point of view, we can transparently switch from this state
to a driver handled in the HID subsystem and clean up a lot of USB specific
code in the wacom.ko driver.

The other benefit once the USB dependecies have been removed is that we can
use a tool like uhid to make regression tests and allow further cleanup or
new implementations without risking breaking current behaviors.

To match the current handling of devices in wacom_wac.c, we rely on the
hid_type set by usbhid. usbhid sets the hid_type to HID_TYPE_USBMOUSE when
it sees a USB boot mouse protocol declared and HID_TYPE_USBNONE when the
device is plain HID. There is thus a one to one matching between the list
of supported devices before and after the switch from USB to HID.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/hid/hid-core.c | 15 ++-
drivers/hid/hid-wacom.c | 2 +-
drivers/input/tablet/wacom.h | 6 +-
drivers/input/tablet/wacom_sys.c | 223 ++++++++++++++-------------------------
drivers/input/tablet/wacom_wac.c | 80 +++++++-------
drivers/input/tablet/wacom_wac.h | 4 +-
include/linux/hid.h | 1 +
7 files changed, 139 insertions(+), 192 deletions(-)

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 2ce3f7a..9db1f42 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -782,10 +782,16 @@ static int hid_scan_report(struct hid_device *hid)
/*
* Vendor specific handlings
*/
- if ((hid->vendor == USB_VENDOR_ID_SYNAPTICS) &&
- (hid->group == HID_GROUP_GENERIC))
- /* hid-rmi should take care of them, not hid-generic */
- hid->group = HID_GROUP_RMI;
+ switch (hid->vendor) {
+ case USB_VENDOR_ID_SYNAPTICS:
+ if (hid->group == HID_GROUP_GENERIC)
+ /* hid-rmi should take care of them, not hid-generic */
+ hid->group = HID_GROUP_RMI;
+ break;
+ case USB_VENDOR_ID_WACOM:
+ hid->group = HID_GROUP_WACOM;
+ break;
+ }

vfree(parser);
return 0;
@@ -2340,7 +2346,6 @@ static const struct hid_device_id hid_ignore_list[] = {
{ HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_SKIP) },
{ HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_CYCLOPS) },
{ HID_USB_DEVICE(USB_VENDOR_ID_VERNIER, USB_DEVICE_ID_VERNIER_LCSPEC) },
- { HID_USB_DEVICE(USB_VENDOR_ID_WACOM, HID_ANY_ID) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_4_PHIDGETSERVO_20) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_1_PHIDGETSERVO_20) },
{ HID_USB_DEVICE(USB_VENDOR_ID_WISEGROUP, USB_DEVICE_ID_8_8_4_IF_KIT) },
diff --git a/drivers/hid/hid-wacom.c b/drivers/hid/hid-wacom.c
index 902013e..4874f4e 100644
--- a/drivers/hid/hid-wacom.c
+++ b/drivers/hid/hid-wacom.c
@@ -960,7 +960,7 @@ static const struct hid_device_id wacom_devices[] = {
MODULE_DEVICE_TABLE(hid, wacom_devices);

static struct hid_driver wacom_driver = {
- .name = "wacom",
+ .name = "hid-wacom",
.id_table = wacom_devices,
.probe = wacom_probe,
.remove = wacom_remove,
diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index 2386ad4..a931221 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -106,14 +106,12 @@ MODULE_LICENSE(DRIVER_LICENSE);
#define USB_VENDOR_ID_LENOVO 0x17ef

struct wacom {
- dma_addr_t data_dma;
struct usb_device *usbdev;
struct usb_interface *intf;
- struct urb *irq;
struct wacom_wac wacom_wac;
+ struct hid_device *hdev;
struct mutex lock;
struct work_struct work;
- bool open;
char phys[32];
struct wacom_led {
u8 select[2]; /* status led selector (0..3) */
@@ -131,7 +129,7 @@ static inline void wacom_schedule_work(struct wacom_wac *wacom_wac)
schedule_work(&wacom->work);
}

-extern const struct usb_device_id wacom_ids[];
+extern const struct hid_device_id wacom_ids[];

void wacom_wac_irq(struct wacom_wac *wacom_wac, size_t len);
void wacom_setup_device_quirks(struct wacom_features *features);
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index e0c1cb2..aa2a4d7 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -83,86 +83,40 @@ static int wacom_set_report(struct usb_interface *intf, u8 type, u8 id,
return retval;
}

-static void wacom_sys_irq(struct urb *urb)
+static int wacom_raw_event(struct hid_device *hdev, struct hid_report *report,
+ u8 *raw_data, int size)
{
- struct wacom *wacom = urb->context;
- struct device *dev = &wacom->intf->dev;
- int retval;
+ struct wacom *wacom = hid_get_drvdata(hdev);

- switch (urb->status) {
- case 0:
- /* success */
- break;
- case -ECONNRESET:
- case -ENOENT:
- case -ESHUTDOWN:
- /* this urb is terminated, clean up */
- dev_dbg(dev, "%s - urb shutting down with status: %d\n",
- __func__, urb->status);
- return;
- default:
- dev_dbg(dev, "%s - nonzero urb status received: %d\n",
- __func__, urb->status);
- goto exit;
- }
+ if (size > WACOM_PKGLEN_MAX)
+ return 1;
+
+ memcpy(wacom->wacom_wac.data, raw_data, size);

- wacom_wac_irq(&wacom->wacom_wac, urb->actual_length);
+ wacom_wac_irq(&wacom->wacom_wac, size);

- exit:
- usb_mark_last_busy(wacom->usbdev);
- retval = usb_submit_urb(urb, GFP_ATOMIC);
- if (retval)
- dev_err(dev, "%s - usb_submit_urb failed with result %d\n",
- __func__, retval);
+ return 0;
}

static int wacom_open(struct input_dev *dev)
{
struct wacom *wacom = input_get_drvdata(dev);
- int retval = 0;
-
- if (usb_autopm_get_interface(wacom->intf) < 0)
- return -EIO;
+ int retval;

mutex_lock(&wacom->lock);
-
- if (wacom->open)
- goto out;
-
- if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
- retval = -EIO;
- goto out;
- }
-
- wacom->open = true;
- wacom->intf->needs_remote_wakeup = 1;
-
-out:
+ retval = hid_hw_open(wacom->hdev);
mutex_unlock(&wacom->lock);
- usb_autopm_put_interface(wacom->intf);
+
return retval;
}

static void wacom_close(struct input_dev *dev)
{
struct wacom *wacom = input_get_drvdata(dev);
- int autopm_error;
-
- autopm_error = usb_autopm_get_interface(wacom->intf);

mutex_lock(&wacom->lock);
- if (!wacom->open)
- goto out;
-
- usb_kill_urb(wacom->irq);
- wacom->open = false;
- wacom->intf->needs_remote_wakeup = 0;
-
-out:
+ hid_hw_close(wacom->hdev);
mutex_unlock(&wacom->lock);
-
- if (!autopm_error)
- usb_autopm_put_interface(wacom->intf);
}

/*
@@ -807,7 +761,8 @@ out:
static ssize_t wacom_led_select_store(struct device *dev, int set_id,
const char *buf, size_t count)
{
- struct wacom *wacom = dev_get_drvdata(dev);
+ struct hid_device *hdev = dev_get_drvdata(dev);
+ struct wacom *wacom = hid_get_drvdata(hdev);
unsigned int id;
int err;

@@ -834,7 +789,8 @@ static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
- struct wacom *wacom = dev_get_drvdata(dev); \
+ struct hid_device *hdev = dev_get_drvdata(dev); \
+ struct wacom *wacom = hid_get_drvdata(hdev); \
return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \
} \
static DEVICE_ATTR(status_led##SET_ID##_select, S_IWUSR | S_IRUSR, \
@@ -868,7 +824,8 @@ static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest,
static ssize_t wacom_##name##_luminance_store(struct device *dev, \
struct device_attribute *attr, const char *buf, size_t count) \
{ \
- struct wacom *wacom = dev_get_drvdata(dev); \
+ struct hid_device *hdev = dev_get_drvdata(dev); \
+ struct wacom *wacom = hid_get_drvdata(hdev); \
\
return wacom_luminance_store(wacom, &wacom->led.field, \
buf, count); \
@@ -883,7 +840,8 @@ DEVICE_LUMINANCE_ATTR(buttons, img_lum);
static ssize_t wacom_button_image_store(struct device *dev, int button_id,
const char *buf, size_t count)
{
- struct wacom *wacom = dev_get_drvdata(dev);
+ struct hid_device *hdev = dev_get_drvdata(dev);
+ struct wacom *wacom = hid_get_drvdata(hdev);
int err;

if (count != 1024)
@@ -1197,6 +1155,7 @@ static void wacom_wireless_work(struct work_struct *work)
struct wacom *wacom = container_of(work, struct wacom, work);
struct usb_device *usbdev = wacom->usbdev;
struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+ struct hid_device *hdev1, *hdev2;
struct wacom *wacom1, *wacom2;
struct wacom_wac *wacom_wac1, *wacom_wac2;
int error;
@@ -1209,14 +1168,16 @@ static void wacom_wireless_work(struct work_struct *work)
wacom_destroy_battery(wacom);

/* Stylus interface */
- wacom1 = usb_get_intfdata(usbdev->config->interface[1]);
+ hdev1 = usb_get_intfdata(usbdev->config->interface[1]);
+ wacom1 = hid_get_drvdata(hdev1);
wacom_wac1 = &(wacom1->wacom_wac);
if (wacom_wac1->input)
input_unregister_device(wacom_wac1->input);
wacom_wac1->input = NULL;

/* Touch interface */
- wacom2 = usb_get_intfdata(usbdev->config->interface[2]);
+ hdev2 = usb_get_intfdata(usbdev->config->interface[2]);
+ wacom2 = hid_get_drvdata(hdev2);
wacom_wac2 = &(wacom2->wacom_wac);
if (wacom_wac2->input)
input_unregister_device(wacom_wac2->input);
@@ -1225,20 +1186,20 @@ static void wacom_wireless_work(struct work_struct *work)
if (wacom_wac->pid == 0) {
dev_info(&wacom->intf->dev, "wireless tablet disconnected\n");
} else {
- const struct usb_device_id *id = wacom_ids;
+ const struct hid_device_id *id = wacom_ids;

dev_info(&wacom->intf->dev,
"wireless tablet connected with PID %x\n",
wacom_wac->pid);

- while (id->match_flags) {
- if (id->idVendor == USB_VENDOR_ID_WACOM &&
- id->idProduct == wacom_wac->pid)
+ while (id->bus) {
+ if (id->vendor == USB_VENDOR_ID_WACOM &&
+ id->product == wacom_wac->pid)
break;
id++;
}

- if (!id->match_flags) {
+ if (!id->bus) {
dev_info(&wacom->intf->dev,
"ignoring unknown PID.\n");
return;
@@ -1246,7 +1207,7 @@ static void wacom_wireless_work(struct work_struct *work)

/* Stylus interface */
wacom_wac1->features =
- *((struct wacom_features *)id->driver_info);
+ *((struct wacom_features *)id->driver_data);
wacom_wac1->features.device_type = BTN_TOOL_PEN;
snprintf(wacom_wac1->name, WACOM_NAME_MAX, "%s (WL) Pen",
wacom_wac1->features.name);
@@ -1260,7 +1221,7 @@ static void wacom_wireless_work(struct work_struct *work)
if (wacom_wac1->features.touch_max ||
wacom_wac1->features.type == INTUOSHT) {
wacom_wac2->features =
- *((struct wacom_features *)id->driver_info);
+ *((struct wacom_features *)id->driver_data);
wacom_wac2->features.pktlen = WACOM_PKGLEN_BBTOUCH3;
wacom_wac2->features.device_type = BTN_TOOL_FINGER;
wacom_wac2->features.x_max = wacom_wac2->features.y_max = 4096;
@@ -1326,8 +1287,10 @@ static void wacom_calculate_res(struct wacom_features *features)
features->unitExpo);
}

-static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *id)
+static int wacom_probe(struct hid_device *hdev,
+ const struct hid_device_id *id)
{
+ struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
struct usb_device *dev = interface_to_usbdev(intf);
struct usb_endpoint_descriptor *endpoint;
struct wacom *wacom;
@@ -1335,34 +1298,29 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
struct wacom_features *features;
int error;

- if (!id->driver_info)
+ if (!id->driver_data)
return -EINVAL;

wacom = kzalloc(sizeof(struct wacom), GFP_KERNEL);
if (!wacom)
return -ENOMEM;

+ hid_set_drvdata(hdev, wacom);
+ wacom->hdev = hdev;
+
wacom_wac = &wacom->wacom_wac;
- wacom_wac->features = *((struct wacom_features *)id->driver_info);
+ wacom_wac->features = *((struct wacom_features *)id->driver_data);
features = &wacom_wac->features;
if (features->pktlen > WACOM_PKGLEN_MAX) {
error = -EINVAL;
goto fail1;
}

- wacom_wac->data = usb_alloc_coherent(dev, WACOM_PKGLEN_MAX,
- GFP_KERNEL, &wacom->data_dma);
- if (!wacom_wac->data) {
- error = -ENOMEM;
+ if (features->check_for_hid_type && features->hid_type != hdev->type) {
+ error = -ENODEV;
goto fail1;
}

- wacom->irq = usb_alloc_urb(0, GFP_KERNEL);
- if (!wacom->irq) {
- error = -ENOMEM;
- goto fail2;
- }
-
wacom->usbdev = dev;
wacom->intf = intf;
mutex_init(&wacom->lock);
@@ -1378,7 +1336,7 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
/* Retrieve the physical and logical size for touch devices */
error = wacom_retrieve_hid_descriptor(intf, features);
if (error)
- goto fail3;
+ goto fail1;

/*
* Intuos5 has no useful data about its touch interface in its
@@ -1426,38 +1384,38 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i
other_dev = dev;
error = wacom_add_shared_data(wacom_wac, other_dev);
if (error)
- goto fail3;
+ goto fail1;
}

- usb_fill_int_urb(wacom->irq, dev,
- usb_rcvintpipe(dev, endpoint->bEndpointAddress),
- wacom_wac->data, features->pktlen,
- wacom_sys_irq, wacom, endpoint->bInterval);
- wacom->irq->transfer_dma = wacom->data_dma;
- wacom->irq->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
-
error = wacom_initialize_leds(wacom);
if (error)
- goto fail4;
+ goto fail2;

if (!(features->quirks & WACOM_QUIRK_NO_INPUT)) {
error = wacom_register_input(wacom);
if (error)
- goto fail5;
+ goto fail3;
}

/* Note that if query fails it is not a hard failure */
wacom_query_tablet_data(intf, features);

- usb_set_intfdata(intf, wacom);
+ /* Regular HID work starts now */
+ error = hid_parse(hdev);
+ if (error) {
+ hid_err(hdev, "parse failed\n");
+ goto fail4;
+ }

- if (features->quirks & WACOM_QUIRK_MONITOR) {
- if (usb_submit_urb(wacom->irq, GFP_KERNEL)) {
- error = -EIO;
- goto fail5;
- }
+ error = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
+ if (error) {
+ hid_err(hdev, "hw start failed\n");
+ goto fail4;
}

+ if (features->quirks & WACOM_QUIRK_MONITOR)
+ error = hid_hw_open(hdev);
+
if (wacom_wac->features.type == INTUOSHT && wacom_wac->features.touch_max) {
if (wacom_wac->features.device_type == BTN_TOOL_FINGER)
wacom_wac->shared->touch_input = wacom_wac->input;
@@ -1465,21 +1423,21 @@ static int wacom_probe(struct usb_interface *intf, const struct usb_device_id *i

return 0;

- fail5: wacom_destroy_leds(wacom);
- fail4: wacom_remove_shared_data(wacom_wac);
- fail3: usb_free_urb(wacom->irq);
- fail2: usb_free_coherent(dev, WACOM_PKGLEN_MAX, wacom_wac->data, wacom->data_dma);
+ fail4: if (wacom->wacom_wac.input)
+ input_unregister_device(wacom->wacom_wac.input);
+ fail3: wacom_destroy_leds(wacom);
+ fail2: wacom_remove_shared_data(wacom_wac);
fail1: kfree(wacom);
+ hid_set_drvdata(hdev, NULL);
return error;
}

-static void wacom_disconnect(struct usb_interface *intf)
+static void wacom_remove(struct hid_device *hdev)
{
- struct wacom *wacom = usb_get_intfdata(intf);
+ struct wacom *wacom = hid_get_drvdata(hdev);

- usb_set_intfdata(intf, NULL);
+ hid_hw_stop(hdev);

- usb_kill_urb(wacom->irq);
cancel_work_sync(&wacom->work);
if (wacom->wacom_wac.input)
input_unregister_device(wacom->wacom_wac.input);
@@ -1487,59 +1445,42 @@ static void wacom_disconnect(struct usb_interface *intf)
input_unregister_device(wacom->wacom_wac.pad_input);
wacom_destroy_battery(wacom);
wacom_destroy_leds(wacom);
- usb_free_urb(wacom->irq);
- usb_free_coherent(interface_to_usbdev(intf), WACOM_PKGLEN_MAX,
- wacom->wacom_wac.data, wacom->data_dma);
wacom_remove_shared_data(&wacom->wacom_wac);
- kfree(wacom);
-}
-
-static int wacom_suspend(struct usb_interface *intf, pm_message_t message)
-{
- struct wacom *wacom = usb_get_intfdata(intf);
-
- mutex_lock(&wacom->lock);
- usb_kill_urb(wacom->irq);
- mutex_unlock(&wacom->lock);

- return 0;
+ hid_set_drvdata(hdev, NULL);
+ kfree(wacom);
}

-static int wacom_resume(struct usb_interface *intf)
+static int wacom_resume(struct hid_device *hdev)
{
- struct wacom *wacom = usb_get_intfdata(intf);
+ struct wacom *wacom = hid_get_drvdata(hdev);
struct wacom_features *features = &wacom->wacom_wac.features;
- int rv = 0;

mutex_lock(&wacom->lock);

/* switch to wacom mode first */
- wacom_query_tablet_data(intf, features);
+ wacom_query_tablet_data(wacom->intf, features);
wacom_led_control(wacom);

- if ((wacom->open || (features->quirks & WACOM_QUIRK_MONITOR)) &&
- usb_submit_urb(wacom->irq, GFP_NOIO) < 0)
- rv = -EIO;
-
mutex_unlock(&wacom->lock);

- return rv;
+ return 0;
}

-static int wacom_reset_resume(struct usb_interface *intf)
+static int wacom_reset_resume(struct hid_device *hdev)
{
- return wacom_resume(intf);
+ return wacom_resume(hdev);
}

-static struct usb_driver wacom_driver = {
+static struct hid_driver wacom_driver = {
.name = "wacom",
.id_table = wacom_ids,
.probe = wacom_probe,
- .disconnect = wacom_disconnect,
- .suspend = wacom_suspend,
+ .remove = wacom_remove,
+#ifdef CONFIG_PM
.resume = wacom_resume,
.reset_resume = wacom_reset_resume,
- .supports_autosuspend = 1,
+#endif
+ .raw_event = wacom_raw_event,
};
-
-module_usb_driver(wacom_driver);
+module_hid_driver(wacom_driver);
diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index f170277..1c95ce7 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -2197,15 +2197,18 @@ static const struct wacom_features wacom_features_0x2A =
static const struct wacom_features wacom_features_0x314 =
{ "Wacom Intuos Pro S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
63, INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
- .touch_max = 16 };
+ .touch_max = 16,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x315 =
{ "Wacom Intuos Pro M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
63, INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
- .touch_max = 16 };
+ .touch_max = 16,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x317 =
{ "Wacom Intuos Pro L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
63, INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
- .touch_max = 16 };
+ .touch_max = 16,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0xF4 =
{ "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104280, 65400, 2047,
63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
@@ -2215,7 +2218,8 @@ static const struct wacom_features wacom_features_0xF8 =
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
static const struct wacom_features wacom_features_0xF6 =
{ "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
- .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10 };
+ .oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x3F =
{ "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
@@ -2233,7 +2237,8 @@ static const struct wacom_features wacom_features_0xC7 =
0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xCE =
{ "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511,
- 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
static const struct wacom_features wacom_features_0xF0 =
{ "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -2249,7 +2254,8 @@ static const struct wacom_features wacom_features_0x59 = /* Pen */
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
static const struct wacom_features wacom_features_0x5D = /* Touch */
{ "Wacom DTH2242", .type = WACOM_24HDT,
- .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10 };
+ .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0xCC =
{ "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87000, 65400, 2047,
63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
@@ -2262,7 +2268,8 @@ static const struct wacom_features wacom_features_0x5B =
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
static const struct wacom_features wacom_features_0x5E =
{ "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
- .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10 };
+ .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x90 =
{ "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -2400,14 +2407,17 @@ static const struct wacom_features wacom_features_0x301 =
static const struct wacom_features wacom_features_0x302 =
{ "Wacom Intuos PT S", WACOM_PKGLEN_BBPEN, 15200, 9500, 1023,
31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 16 };
+ .touch_max = 16,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x303 =
{ "Wacom Intuos PT M", WACOM_PKGLEN_BBPEN, 21600, 13500, 1023,
31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 16 };
+ .touch_max = 16,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x30E =
{ "Wacom Intuos S", WACOM_PKGLEN_BBPEN, 15200, 9500, 1023,
- 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x6004 =
{ "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
@@ -2417,22 +2427,18 @@ static const struct wacom_features wacom_features_0x0307 =
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
static const struct wacom_features wacom_features_0x0309 =
{ "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
- .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10 };
-
-#define USB_DEVICE_WACOM(prod) \
- USB_DEVICE(USB_VENDOR_ID_WACOM, prod), \
- .driver_info = (kernel_ulong_t)&wacom_features_##prod
+ .oVid = USB_VENDOR_ID_WACOM, .oPid = 0x0307, .touch_max = 10,
+ .check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };

-#define USB_DEVICE_DETAILED(prod, class, sub, proto) \
- USB_DEVICE_AND_INTERFACE_INFO(USB_VENDOR_ID_WACOM, prod, class, \
- sub, proto), \
- .driver_info = (kernel_ulong_t)&wacom_features_##prod
+#define USB_DEVICE_WACOM(prod) \
+ HID_DEVICE(BUS_USB, HID_GROUP_WACOM, USB_VENDOR_ID_WACOM, prod),\
+ .driver_data = (kernel_ulong_t)&wacom_features_##prod

#define USB_DEVICE_LENOVO(prod) \
- USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
- .driver_info = (kernel_ulong_t)&wacom_features_##prod
+ HID_USB_DEVICE(USB_VENDOR_ID_LENOVO, prod), \
+ .driver_data = (kernel_ulong_t)&wacom_features_##prod

-const struct usb_device_id wacom_ids[] = {
+const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x00) },
{ USB_DEVICE_WACOM(0x10) },
{ USB_DEVICE_WACOM(0x11) },
@@ -2478,9 +2484,9 @@ const struct usb_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x45) },
{ USB_DEVICE_WACOM(0x57) },
{ USB_DEVICE_WACOM(0x59) },
- { USB_DEVICE_DETAILED(0x5D, USB_CLASS_HID, 0, 0) },
+ { USB_DEVICE_WACOM(0x5D) },
{ USB_DEVICE_WACOM(0x5B) },
- { USB_DEVICE_DETAILED(0x5E, USB_CLASS_HID, 0, 0) },
+ { USB_DEVICE_WACOM(0x5E) },
{ USB_DEVICE_WACOM(0xB0) },
{ USB_DEVICE_WACOM(0xB1) },
{ USB_DEVICE_WACOM(0xB2) },
@@ -2502,13 +2508,7 @@ const struct usb_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0xC5) },
{ USB_DEVICE_WACOM(0xC6) },
{ USB_DEVICE_WACOM(0xC7) },
- /*
- * DTU-2231 has two interfaces on the same configuration,
- * only one is used.
- */
- { USB_DEVICE_DETAILED(0xCE, USB_CLASS_HID,
- USB_INTERFACE_SUBCLASS_BOOT,
- USB_INTERFACE_PROTOCOL_MOUSE) },
+ { USB_DEVICE_WACOM(0xCE) },
{ USB_DEVICE_WACOM(0x84) },
{ USB_DEVICE_WACOM(0xD0) },
{ USB_DEVICE_WACOM(0xD1) },
@@ -2546,13 +2546,13 @@ const struct usb_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x116) },
{ USB_DEVICE_WACOM(0x300) },
{ USB_DEVICE_WACOM(0x301) },
- { USB_DEVICE_DETAILED(0x302, USB_CLASS_HID, 0, 0) },
- { USB_DEVICE_DETAILED(0x303, USB_CLASS_HID, 0, 0) },
- { USB_DEVICE_DETAILED(0x30E, USB_CLASS_HID, 0, 0) },
+ { USB_DEVICE_WACOM(0x302) },
+ { USB_DEVICE_WACOM(0x303) },
+ { USB_DEVICE_WACOM(0x30E) },
{ USB_DEVICE_WACOM(0x304) },
- { USB_DEVICE_DETAILED(0x314, USB_CLASS_HID, 0, 0) },
- { USB_DEVICE_DETAILED(0x315, USB_CLASS_HID, 0, 0) },
- { USB_DEVICE_DETAILED(0x317, USB_CLASS_HID, 0, 0) },
+ { USB_DEVICE_WACOM(0x314) },
+ { USB_DEVICE_WACOM(0x315) },
+ { USB_DEVICE_WACOM(0x317) },
{ USB_DEVICE_WACOM(0x4001) },
{ USB_DEVICE_WACOM(0x4004) },
{ USB_DEVICE_WACOM(0x5000) },
@@ -2560,12 +2560,12 @@ const struct usb_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x47) },
{ USB_DEVICE_WACOM(0xF4) },
{ USB_DEVICE_WACOM(0xF8) },
- { USB_DEVICE_DETAILED(0xF6, USB_CLASS_HID, 0, 0) },
+ { USB_DEVICE_WACOM(0xF6) },
{ USB_DEVICE_WACOM(0xFA) },
{ USB_DEVICE_WACOM(0xFB) },
{ USB_DEVICE_WACOM(0x0307) },
- { USB_DEVICE_DETAILED(0x0309, USB_CLASS_HID, 0, 0) },
+ { USB_DEVICE_WACOM(0x0309) },
{ USB_DEVICE_LENOVO(0x6004) },
{ }
};
-MODULE_DEVICE_TABLE(usb, wacom_ids);
+MODULE_DEVICE_TABLE(hid, wacom_ids);
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index f48164c..8821a51 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -137,6 +137,8 @@ struct wacom_features {
unsigned touch_max;
int oVid;
int oPid;
+ bool check_for_hid_type;
+ int hid_type;
};

struct wacom_shared {
@@ -151,7 +153,7 @@ struct wacom_shared {
struct wacom_wac {
char name[WACOM_NAME_MAX];
char pad_name[WACOM_NAME_MAX];
- unsigned char *data;
+ unsigned char data[WACOM_PKGLEN_MAX];
int tool[2];
int id[2];
__u32 serial[2];
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 77632cf..9732299 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -309,6 +309,7 @@ struct hid_item {
* Vendor specific HID device groups
*/
#define HID_GROUP_RMI 0x0100
+#define HID_GROUP_WACOM 0x0101

/*
* This is the global environment of the parser. This information is
--
2.0.0

2014-06-30 21:26:55

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 10/15] Input - wacom: use hid_info instead of plain dev_info

Removes one more need of usb and intf.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 2313f1a..2208b4a 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -1101,12 +1101,11 @@ static void wacom_wireless_work(struct work_struct *work)
wacom_wac2->input = NULL;

if (wacom_wac->pid == 0) {
- dev_info(&wacom->intf->dev, "wireless tablet disconnected\n");
+ hid_info(wacom->hdev, "wireless tablet disconnected\n");
} else {
const struct hid_device_id *id = wacom_ids;

- dev_info(&wacom->intf->dev,
- "wireless tablet connected with PID %x\n",
+ hid_info(wacom->hdev, "wireless tablet connected with PID %x\n",
wacom_wac->pid);

while (id->bus) {
@@ -1117,8 +1116,7 @@ static void wacom_wireless_work(struct work_struct *work)
}

if (!id->bus) {
- dev_info(&wacom->intf->dev,
- "ignoring unknown PID.\n");
+ hid_info(wacom->hdev, "ignoring unknown PID.\n");
return;
}

--
2.0.0

2014-06-30 21:26:52

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 08/15] Input - wacom: remove usb dependency for siblings devices

Wacom tablets can share different physical sensors on one physical device.
These are called siblings in the code. The current way of implementation
relies on the USB topology to be able to share data amongs those sensors.

We can replace the code to match a HID subsystem, without involving the USB
topology:
- the first probed sensor does not find any siblings in the list
wacom_udev_list, so it creates its own wacom_hdev_data with its own
struct hid_device
- the other sensor checks the current list of siblings in wacom_hdev_data,
and if there is a match, it associates itself to the matched device.

To be sure that we are not associating different sensors from different
physical devices, we also check for the phys path of the hid device which
contains the USB topology.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 75 +++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 40 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 0d0397d..6fe7a6c 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -488,46 +488,45 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
return error;
}

-struct wacom_usbdev_data {
+struct wacom_hdev_data {
struct list_head list;
struct kref kref;
- struct usb_device *dev;
+ struct hid_device *dev;
struct wacom_shared shared;
};

static LIST_HEAD(wacom_udev_list);
static DEFINE_MUTEX(wacom_udev_list_lock);

-static struct usb_device *wacom_get_sibling(struct usb_device *dev, int vendor, int product)
+static bool wacom_are_sibling(struct hid_device *hdev,
+ struct hid_device *sibling)
{
- int port1;
- struct usb_device *sibling;
-
- if (vendor == 0 && product == 0)
- return dev;
-
- if (dev->parent == NULL)
- return NULL;
-
- usb_hub_for_each_child(dev->parent, port1, sibling) {
- struct usb_device_descriptor *d;
- if (sibling == NULL)
- continue;
+ struct wacom *wacom = hid_get_drvdata(hdev);
+ struct wacom_features *features = &wacom->wacom_wac.features;
+ int vid = features->oVid;
+ int pid = features->oPid;

- d = &sibling->descriptor;
- if (d->idVendor == vendor && d->idProduct == product)
- return sibling;
+ if (vid == 0 && pid == 0) {
+ vid = hdev->vendor;
+ pid = hdev->product;
}

- return NULL;
+ if (vid != sibling->vendor || pid != sibling->product)
+ return false;
+
+ /*
+ * Compare the physical path.
+ * Dump the last two chars which should contain the input number.
+ */
+ return !strncmp(hdev->phys, sibling->phys, strlen(hdev->phys) - 2);
}

-static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
+static struct wacom_hdev_data *wacom_get_hdev_data(struct hid_device *hdev)
{
- struct wacom_usbdev_data *data;
+ struct wacom_hdev_data *data;

list_for_each_entry(data, &wacom_udev_list, list) {
- if (data->dev == dev) {
+ if (wacom_are_sibling(hdev, data->dev)) {
kref_get(&data->kref);
return data;
}
@@ -536,28 +535,29 @@ static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
return NULL;
}

-static int wacom_add_shared_data(struct wacom_wac *wacom,
- struct usb_device *dev)
+static int wacom_add_shared_data(struct hid_device *hdev)
{
- struct wacom_usbdev_data *data;
+ struct wacom *wacom = hid_get_drvdata(hdev);
+ struct wacom_wac *wacom_wac = &wacom->wacom_wac;
+ struct wacom_hdev_data *data;
int retval = 0;

mutex_lock(&wacom_udev_list_lock);

- data = wacom_get_usbdev_data(dev);
+ data = wacom_get_hdev_data(hdev);
if (!data) {
- data = kzalloc(sizeof(struct wacom_usbdev_data), GFP_KERNEL);
+ data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL);
if (!data) {
retval = -ENOMEM;
goto out;
}

kref_init(&data->kref);
- data->dev = dev;
+ data->dev = hdev;
list_add_tail(&data->list, &wacom_udev_list);
}

- wacom->shared = &data->shared;
+ wacom_wac->shared = &data->shared;

out:
mutex_unlock(&wacom_udev_list_lock);
@@ -566,8 +566,8 @@ out:

static void wacom_release_shared_data(struct kref *kref)
{
- struct wacom_usbdev_data *data =
- container_of(kref, struct wacom_usbdev_data, kref);
+ struct wacom_hdev_data *data =
+ container_of(kref, struct wacom_hdev_data, kref);

mutex_lock(&wacom_udev_list_lock);
list_del(&data->list);
@@ -578,10 +578,10 @@ static void wacom_release_shared_data(struct kref *kref)

static void wacom_remove_shared_data(struct wacom_wac *wacom)
{
- struct wacom_usbdev_data *data;
+ struct wacom_hdev_data *data;

if (wacom->shared) {
- data = container_of(wacom->shared, struct wacom_usbdev_data, shared);
+ data = container_of(wacom->shared, struct wacom_hdev_data, shared);
kref_put(&data->kref, wacom_release_shared_data);
wacom->shared = NULL;
}
@@ -1311,8 +1311,6 @@ static int wacom_probe(struct hid_device *hdev,
"%s Pad", features->name);

if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
- struct usb_device *other_dev;
-
/* Append the device type to the name */
if (features->device_type != BTN_TOOL_FINGER)
strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX);
@@ -1321,10 +1319,7 @@ static int wacom_probe(struct hid_device *hdev,
else
strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX);

- other_dev = wacom_get_sibling(dev, features->oVid, features->oPid);
- if (other_dev == NULL || wacom_get_usbdev_data(other_dev) == NULL)
- other_dev = dev;
- error = wacom_add_shared_data(wacom_wac, other_dev);
+ error = wacom_add_shared_data(hdev);
if (error)
goto fail1;
}
--
2.0.0

2014-06-30 21:27:00

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 13/15] Input - wacom: use hidinput_calc_abs_res instead of duplicating its code

This may infer a small difference with the previous implementation
due to the DIV_ROUND_CLOSEST() in the hid implementation.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 48 ++++++++--------------------------------
1 file changed, 9 insertions(+), 39 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index eab299c..a8294d4 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -85,49 +85,19 @@ static void wacom_close(struct input_dev *dev)
}

/*
- * Calculate the resolution of the X or Y axis, given appropriate HID data.
- * This function is little more than hidinput_calc_abs_res stripped down.
+ * Calculate the resolution of the X or Y axis using hidinput_calc_abs_res.
*/
static int wacom_calc_hid_res(int logical_extents, int physical_extents,
unsigned unit, int exponent)
{
- int prev;
- int unit_exponent = exponent;
-
- /* Check if the extents are sane */
- if (logical_extents <= 0 || physical_extents <= 0)
- return 0;
-
- /* Convert physical_extents to millimeters */
- if (unit == 0x11) { /* If centimeters */
- unit_exponent += 1;
- } else if (unit == 0x13) { /* If inches */
- prev = physical_extents;
- physical_extents *= 254;
- if (physical_extents < prev)
- return 0;
- unit_exponent -= 1;
- } else {
- return 0;
- }
-
- /* Apply negative unit exponent */
- for (; unit_exponent < 0; unit_exponent++) {
- prev = logical_extents;
- logical_extents *= 10;
- if (logical_extents < prev)
- return 0;
- }
- /* Apply positive unit exponent */
- for (; unit_exponent > 0; unit_exponent--) {
- prev = physical_extents;
- physical_extents *= 10;
- if (physical_extents < prev)
- return 0;
- }
-
- /* Calculate resolution */
- return logical_extents / physical_extents;
+ struct hid_field field = {
+ .logical_maximum = logical_extents,
+ .physical_maximum = physical_extents,
+ .unit = unit,
+ .unit_exponent = exponent
+ };
+
+ return hidinput_calc_abs_res(&field, ABS_X);
}

static void wacom_feature_mapping(struct hid_device *hdev,
--
2.0.0

2014-06-30 21:27:07

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 15/15] Input - wacom: keep wacom_ids ordered

No Functional changes, just some reordering.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_wac.c | 75 ++++++++++++++++++++--------------------
1 file changed, 37 insertions(+), 38 deletions(-)

diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 15b0132..de033d5 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -2418,6 +2418,7 @@ static const struct wacom_features wacom_features_0x0309 =

const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x00) },
+ { USB_DEVICE_WACOM(0x03) },
{ USB_DEVICE_WACOM(0x10) },
{ USB_DEVICE_WACOM(0x11) },
{ USB_DEVICE_WACOM(0x12) },
@@ -2428,20 +2429,16 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x17) },
{ USB_DEVICE_WACOM(0x18) },
{ USB_DEVICE_WACOM(0x19) },
- { USB_DEVICE_WACOM(0x60) },
- { USB_DEVICE_WACOM(0x61) },
- { USB_DEVICE_WACOM(0x62) },
- { USB_DEVICE_WACOM(0x63) },
- { USB_DEVICE_WACOM(0x64) },
- { USB_DEVICE_WACOM(0x65) },
- { USB_DEVICE_WACOM(0x69) },
- { USB_DEVICE_WACOM(0x6A) },
- { USB_DEVICE_WACOM(0x6B) },
{ USB_DEVICE_WACOM(0x20) },
{ USB_DEVICE_WACOM(0x21) },
{ USB_DEVICE_WACOM(0x22) },
{ USB_DEVICE_WACOM(0x23) },
{ USB_DEVICE_WACOM(0x24) },
+ { USB_DEVICE_WACOM(0x26) },
+ { USB_DEVICE_WACOM(0x27) },
+ { USB_DEVICE_WACOM(0x28) },
+ { USB_DEVICE_WACOM(0x29) },
+ { USB_DEVICE_WACOM(0x2A) },
{ USB_DEVICE_WACOM(0x30) },
{ USB_DEVICE_WACOM(0x31) },
{ USB_DEVICE_WACOM(0x32) },
@@ -2451,20 +2448,33 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x37) },
{ USB_DEVICE_WACOM(0x38) },
{ USB_DEVICE_WACOM(0x39) },
- { USB_DEVICE_WACOM(0xC4) },
- { USB_DEVICE_WACOM(0xC0) },
- { USB_DEVICE_WACOM(0xC2) },
- { USB_DEVICE_WACOM(0x03) },
+ { USB_DEVICE_WACOM(0x3F) },
{ USB_DEVICE_WACOM(0x41) },
{ USB_DEVICE_WACOM(0x42) },
{ USB_DEVICE_WACOM(0x43) },
{ USB_DEVICE_WACOM(0x44) },
{ USB_DEVICE_WACOM(0x45) },
+ { USB_DEVICE_WACOM(0x47) },
{ USB_DEVICE_WACOM(0x57) },
{ USB_DEVICE_WACOM(0x59) },
- { USB_DEVICE_WACOM(0x5D) },
{ USB_DEVICE_WACOM(0x5B) },
+ { USB_DEVICE_WACOM(0x5D) },
{ USB_DEVICE_WACOM(0x5E) },
+ { USB_DEVICE_WACOM(0x60) },
+ { USB_DEVICE_WACOM(0x61) },
+ { USB_DEVICE_WACOM(0x62) },
+ { USB_DEVICE_WACOM(0x63) },
+ { USB_DEVICE_WACOM(0x64) },
+ { USB_DEVICE_WACOM(0x65) },
+ { USB_DEVICE_WACOM(0x69) },
+ { USB_DEVICE_WACOM(0x6A) },
+ { USB_DEVICE_WACOM(0x6B) },
+ { USB_DEVICE_WACOM(0x84) },
+ { USB_DEVICE_WACOM(0x90) },
+ { USB_DEVICE_WACOM(0x93) },
+ { USB_DEVICE_WACOM(0x97) },
+ { USB_DEVICE_WACOM(0x9A) },
+ { USB_DEVICE_WACOM(0x9F) },
{ USB_DEVICE_WACOM(0xB0) },
{ USB_DEVICE_WACOM(0xB1) },
{ USB_DEVICE_WACOM(0xB2) },
@@ -2477,17 +2487,14 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0xBA) },
{ USB_DEVICE_WACOM(0xBB) },
{ USB_DEVICE_WACOM(0xBC) },
- { USB_DEVICE_WACOM(0x26) },
- { USB_DEVICE_WACOM(0x27) },
- { USB_DEVICE_WACOM(0x28) },
- { USB_DEVICE_WACOM(0x29) },
- { USB_DEVICE_WACOM(0x2A) },
- { USB_DEVICE_WACOM(0x3F) },
+ { USB_DEVICE_WACOM(0xC0) },
+ { USB_DEVICE_WACOM(0xC2) },
+ { USB_DEVICE_WACOM(0xC4) },
{ USB_DEVICE_WACOM(0xC5) },
{ USB_DEVICE_WACOM(0xC6) },
{ USB_DEVICE_WACOM(0xC7) },
+ { USB_DEVICE_WACOM(0xCC) },
{ USB_DEVICE_WACOM(0xCE) },
- { USB_DEVICE_WACOM(0x84) },
{ USB_DEVICE_WACOM(0xD0) },
{ USB_DEVICE_WACOM(0xD1) },
{ USB_DEVICE_WACOM(0xD2) },
@@ -2502,13 +2509,6 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0xDD) },
{ USB_DEVICE_WACOM(0xDE) },
{ USB_DEVICE_WACOM(0xDF) },
- { USB_DEVICE_WACOM(0xF0) },
- { USB_DEVICE_WACOM(0xCC) },
- { USB_DEVICE_WACOM(0x90) },
- { USB_DEVICE_WACOM(0x93) },
- { USB_DEVICE_WACOM(0x97) },
- { USB_DEVICE_WACOM(0x9A) },
- { USB_DEVICE_WACOM(0x9F) },
{ USB_DEVICE_WACOM(0xE2) },
{ USB_DEVICE_WACOM(0xE3) },
{ USB_DEVICE_WACOM(0xE5) },
@@ -2516,6 +2516,12 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0xEC) },
{ USB_DEVICE_WACOM(0xED) },
{ USB_DEVICE_WACOM(0xEF) },
+ { USB_DEVICE_WACOM(0xF0) },
+ { USB_DEVICE_WACOM(0xF4) },
+ { USB_DEVICE_WACOM(0xF6) },
+ { USB_DEVICE_WACOM(0xF8) },
+ { USB_DEVICE_WACOM(0xFA) },
+ { USB_DEVICE_WACOM(0xFB) },
{ USB_DEVICE_WACOM(0x100) },
{ USB_DEVICE_WACOM(0x101) },
{ USB_DEVICE_WACOM(0x10D) },
@@ -2526,8 +2532,10 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x301) },
{ USB_DEVICE_WACOM(0x302) },
{ USB_DEVICE_WACOM(0x303) },
- { USB_DEVICE_WACOM(0x30E) },
{ USB_DEVICE_WACOM(0x304) },
+ { USB_DEVICE_WACOM(0x307) },
+ { USB_DEVICE_WACOM(0x309) },
+ { USB_DEVICE_WACOM(0x30E) },
{ USB_DEVICE_WACOM(0x314) },
{ USB_DEVICE_WACOM(0x315) },
{ USB_DEVICE_WACOM(0x317) },
@@ -2535,15 +2543,6 @@ const struct hid_device_id wacom_ids[] = {
{ USB_DEVICE_WACOM(0x4004) },
{ USB_DEVICE_WACOM(0x5000) },
{ USB_DEVICE_WACOM(0x5002) },
- { USB_DEVICE_WACOM(0x47) },
- { USB_DEVICE_WACOM(0xF4) },
- { USB_DEVICE_WACOM(0xF8) },
- { USB_DEVICE_WACOM(0xF6) },
- { USB_DEVICE_WACOM(0xFA) },
- { USB_DEVICE_WACOM(0xFB) },
- { USB_DEVICE_WACOM(0x0307) },
- { USB_DEVICE_WACOM(0x0309) },
- { USB_DEVICE_LENOVO(0x6004) },
{ }
};
MODULE_DEVICE_TABLE(hid, wacom_ids);
--
2.0.0

2014-06-30 21:27:06

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 14/15] Input - wacom: remove field pktlen declaration in the list of devices

pktlen is now overwritten by the driver directly by reading the hid
report descriptor. There is no need to declare it statically.
We also move down the position of the field in the struct so that
we can keep the current declaration of Wacom devices.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_wac.c | 514 +++++++++++++++++++--------------------
drivers/input/tablet/wacom_wac.h | 2 +-
2 files changed, 247 insertions(+), 269 deletions(-)

diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
index 1c95ce7..15b0132 100644
--- a/drivers/input/tablet/wacom_wac.c
+++ b/drivers/input/tablet/wacom_wac.c
@@ -2012,418 +2012,396 @@ int wacom_setup_pad_input_capabilities(struct input_dev *input_dev,
}

static const struct wacom_features wacom_features_0x00 =
- { "Wacom Penpartner", WACOM_PKGLEN_PENPRTN, 5040, 3780, 255,
- 0, PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
+ { "Wacom Penpartner", 5040, 3780, 255, 0,
+ PENPARTNER, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
static const struct wacom_features wacom_features_0x10 =
- { "Wacom Graphire", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
- 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+ { "Wacom Graphire", 10206, 7422, 511, 63,
+ GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
static const struct wacom_features wacom_features_0x11 =
- { "Wacom Graphire2 4x5", WACOM_PKGLEN_GRAPHIRE, 10206, 7422, 511,
- 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+ { "Wacom Graphire2 4x5", 10206, 7422, 511, 63,
+ GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
static const struct wacom_features wacom_features_0x12 =
- { "Wacom Graphire2 5x7", WACOM_PKGLEN_GRAPHIRE, 13918, 10206, 511,
- 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+ { "Wacom Graphire2 5x7", 13918, 10206, 511, 63,
+ GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
static const struct wacom_features wacom_features_0x13 =
- { "Wacom Graphire3", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
- 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+ { "Wacom Graphire3", 10208, 7424, 511, 63,
+ GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
static const struct wacom_features wacom_features_0x14 =
- { "Wacom Graphire3 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
- 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+ { "Wacom Graphire3 6x8", 16704, 12064, 511, 63,
+ GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
static const struct wacom_features wacom_features_0x15 =
- { "Wacom Graphire4 4x5", WACOM_PKGLEN_GRAPHIRE, 10208, 7424, 511,
- 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+ { "Wacom Graphire4 4x5", 10208, 7424, 511, 63,
+ WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
static const struct wacom_features wacom_features_0x16 =
- { "Wacom Graphire4 6x8", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
- 63, WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+ { "Wacom Graphire4 6x8", 16704, 12064, 511, 63,
+ WACOM_G4, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
static const struct wacom_features wacom_features_0x17 =
- { "Wacom BambooFun 4x5", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
- 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom BambooFun 4x5", 14760, 9225, 511, 63,
+ WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x18 =
- { "Wacom BambooFun 6x8", WACOM_PKGLEN_BBFUN, 21648, 13530, 511,
- 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom BambooFun 6x8", 21648, 13530, 511, 63,
+ WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x19 =
- { "Wacom Bamboo1 Medium", WACOM_PKGLEN_GRAPHIRE, 16704, 12064, 511,
- 63, GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
+ { "Wacom Bamboo1 Medium", 16704, 12064, 511, 63,
+ GRAPHIRE, WACOM_GRAPHIRE_RES, WACOM_GRAPHIRE_RES };
static const struct wacom_features wacom_features_0x60 =
- { "Wacom Volito", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
- 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
+ { "Wacom Volito", 5104, 3712, 511, 63,
+ GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
static const struct wacom_features wacom_features_0x61 =
- { "Wacom PenStation2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 255,
- 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
+ { "Wacom PenStation2", 3250, 2320, 255, 63,
+ GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
static const struct wacom_features wacom_features_0x62 =
- { "Wacom Volito2 4x5", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
- 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
+ { "Wacom Volito2 4x5", 5104, 3712, 511, 63,
+ GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
static const struct wacom_features wacom_features_0x63 =
- { "Wacom Volito2 2x3", WACOM_PKGLEN_GRAPHIRE, 3248, 2320, 511,
- 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
+ { "Wacom Volito2 2x3", 3248, 2320, 511, 63,
+ GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
static const struct wacom_features wacom_features_0x64 =
- { "Wacom PenPartner2", WACOM_PKGLEN_GRAPHIRE, 3250, 2320, 511,
- 63, GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
+ { "Wacom PenPartner2", 3250, 2320, 511, 63,
+ GRAPHIRE, WACOM_VOLITO_RES, WACOM_VOLITO_RES };
static const struct wacom_features wacom_features_0x65 =
- { "Wacom Bamboo", WACOM_PKGLEN_BBFUN, 14760, 9225, 511,
- 63, WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Bamboo", 14760, 9225, 511, 63,
+ WACOM_MO, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x69 =
- { "Wacom Bamboo1", WACOM_PKGLEN_GRAPHIRE, 5104, 3712, 511,
- 63, GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
+ { "Wacom Bamboo1", 5104, 3712, 511, 63,
+ GRAPHIRE, WACOM_PENPRTN_RES, WACOM_PENPRTN_RES };
static const struct wacom_features wacom_features_0x6A =
- { "Wacom Bamboo1 4x6", WACOM_PKGLEN_GRAPHIRE, 14760, 9225, 1023,
- 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Bamboo1 4x6", 14760, 9225, 1023, 63,
+ GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x6B =
- { "Wacom Bamboo1 5x8", WACOM_PKGLEN_GRAPHIRE, 21648, 13530, 1023,
- 63, GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Bamboo1 5x8", 21648, 13530, 1023, 63,
+ GRAPHIRE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x20 =
- { "Wacom Intuos 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos 4x5", 12700, 10600, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x21 =
- { "Wacom Intuos 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos 6x8", 20320, 16240, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x22 =
- { "Wacom Intuos 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos 9x12", 30480, 24060, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x23 =
- { "Wacom Intuos 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos 12x12", 30480, 31680, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x24 =
- { "Wacom Intuos 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos 12x18", 45720, 31680, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x30 =
- { "Wacom PL400", WACOM_PKGLEN_GRAPHIRE, 5408, 4056, 255,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom PL400", 5408, 4056, 255, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x31 =
- { "Wacom PL500", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 255,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom PL500", 6144, 4608, 255, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x32 =
- { "Wacom PL600", WACOM_PKGLEN_GRAPHIRE, 6126, 4604, 255,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom PL600", 6126, 4604, 255, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x33 =
- { "Wacom PL600SX", WACOM_PKGLEN_GRAPHIRE, 6260, 5016, 255,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom PL600SX", 6260, 5016, 255, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x34 =
- { "Wacom PL550", WACOM_PKGLEN_GRAPHIRE, 6144, 4608, 511,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom PL550", 6144, 4608, 511, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x35 =
- { "Wacom PL800", WACOM_PKGLEN_GRAPHIRE, 7220, 5780, 511,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom PL800", 7220, 5780, 511, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x37 =
- { "Wacom PL700", WACOM_PKGLEN_GRAPHIRE, 6758, 5406, 511,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom PL700", 6758, 5406, 511, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x38 =
- { "Wacom PL510", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom PL510", 6282, 4762, 511, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x39 =
- { "Wacom DTU710", WACOM_PKGLEN_GRAPHIRE, 34080, 27660, 511,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom DTU710", 34080, 27660, 511, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0xC4 =
- { "Wacom DTF521", WACOM_PKGLEN_GRAPHIRE, 6282, 4762, 511,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom DTF521", 6282, 4762, 511, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0xC0 =
- { "Wacom DTF720", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom DTF720", 6858, 5506, 511, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0xC2 =
- { "Wacom DTF720a", WACOM_PKGLEN_GRAPHIRE, 6858, 5506, 511,
- 0, PL, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom DTF720a", 6858, 5506, 511, 0,
+ PL, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x03 =
- { "Wacom Cintiq Partner", WACOM_PKGLEN_GRAPHIRE, 20480, 15360, 511,
- 0, PTU, WACOM_PL_RES, WACOM_PL_RES };
+ { "Wacom Cintiq Partner", 20480, 15360, 511, 0,
+ PTU, WACOM_PL_RES, WACOM_PL_RES };
static const struct wacom_features wacom_features_0x41 =
- { "Wacom Intuos2 4x5", WACOM_PKGLEN_INTUOS, 12700, 10600, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos2 4x5", 12700, 10600, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x42 =
- { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x43 =
- { "Wacom Intuos2 9x12", WACOM_PKGLEN_INTUOS, 30480, 24060, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos2 9x12", 30480, 24060, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x44 =
- { "Wacom Intuos2 12x12", WACOM_PKGLEN_INTUOS, 30480, 31680, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos2 12x12", 30480, 31680, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x45 =
- { "Wacom Intuos2 12x18", WACOM_PKGLEN_INTUOS, 45720, 31680, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos2 12x18", 45720, 31680, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xB0 =
- { "Wacom Intuos3 4x5", WACOM_PKGLEN_INTUOS, 25400, 20320, 1023,
- 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos3 4x5", 25400, 20320, 1023, 63,
+ INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xB1 =
- { "Wacom Intuos3 6x8", WACOM_PKGLEN_INTUOS, 40640, 30480, 1023,
- 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos3 6x8", 40640, 30480, 1023, 63,
+ INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xB2 =
- { "Wacom Intuos3 9x12", WACOM_PKGLEN_INTUOS, 60960, 45720, 1023,
- 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos3 9x12", 60960, 45720, 1023, 63,
+ INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xB3 =
- { "Wacom Intuos3 12x12", WACOM_PKGLEN_INTUOS, 60960, 60960, 1023,
- 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos3 12x12", 60960, 60960, 1023, 63,
+ INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xB4 =
- { "Wacom Intuos3 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 1023,
- 63, INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos3 12x19", 97536, 60960, 1023, 63,
+ INTUOS3L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xB5 =
- { "Wacom Intuos3 6x11", WACOM_PKGLEN_INTUOS, 54204, 31750, 1023,
- 63, INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos3 6x11", 54204, 31750, 1023, 63,
+ INTUOS3, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xB7 =
- { "Wacom Intuos3 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 1023,
- 63, INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos3 4x6", 31496, 19685, 1023, 63,
+ INTUOS3S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xB8 =
- { "Wacom Intuos4 4x6", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
- 63, INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos4 4x6", 31496, 19685, 2047, 63,
+ INTUOS4S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xB9 =
- { "Wacom Intuos4 6x9", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
- 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos4 6x9", 44704, 27940, 2047, 63,
+ INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xBA =
- { "Wacom Intuos4 8x13", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
- 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos4 8x13", 65024, 40640, 2047, 63,
+ INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xBB =
- { "Wacom Intuos4 12x19", WACOM_PKGLEN_INTUOS, 97536, 60960, 2047,
- 63, INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos4 12x19", 97536, 60960, 2047, 63,
+ INTUOS4L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xBC =
- { "Wacom Intuos4 WL", WACOM_PKGLEN_INTUOS, 40640, 25400, 2047,
- 63, INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos4 WL", 40640, 25400, 2047, 63,
+ INTUOS4, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0x26 =
- { "Wacom Intuos5 touch S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
- 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
- .touch_max = 16 };
+ { "Wacom Intuos5 touch S", 31496, 19685, 2047, 63,
+ INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
static const struct wacom_features wacom_features_0x27 =
- { "Wacom Intuos5 touch M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
- 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
- .touch_max = 16 };
+ { "Wacom Intuos5 touch M", 44704, 27940, 2047, 63,
+ INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
static const struct wacom_features wacom_features_0x28 =
- { "Wacom Intuos5 touch L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
- 63, INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
- .touch_max = 16 };
+ { "Wacom Intuos5 touch L", 65024, 40640, 2047, 63,
+ INTUOS5L, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16 };
static const struct wacom_features wacom_features_0x29 =
- { "Wacom Intuos5 S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
- 63, INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos5 S", 31496, 19685, 2047, 63,
+ INTUOS5S, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0x2A =
- { "Wacom Intuos5 M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
- 63, INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Intuos5 M", 44704, 27940, 2047, 63,
+ INTUOS5, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0x314 =
- { "Wacom Intuos Pro S", WACOM_PKGLEN_INTUOS, 31496, 19685, 2047,
- 63, INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
- .touch_max = 16,
+ { "Wacom Intuos Pro S", 31496, 19685, 2047, 63,
+ INTUOSPS, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x315 =
- { "Wacom Intuos Pro M", WACOM_PKGLEN_INTUOS, 44704, 27940, 2047,
- 63, INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
- .touch_max = 16,
+ { "Wacom Intuos Pro M", 44704, 27940, 2047, 63,
+ INTUOSPM, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x317 =
- { "Wacom Intuos Pro L", WACOM_PKGLEN_INTUOS, 65024, 40640, 2047,
- 63, INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES,
- .touch_max = 16,
+ { "Wacom Intuos Pro L", 65024, 40640, 2047, 63,
+ INTUOSPL, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, .touch_max = 16,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0xF4 =
- { "Wacom Cintiq 24HD", WACOM_PKGLEN_INTUOS, 104280, 65400, 2047,
- 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
+ { "Wacom Cintiq 24HD", 104280, 65400, 2047, 63,
+ WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
static const struct wacom_features wacom_features_0xF8 =
- { "Wacom Cintiq 24HD touch", WACOM_PKGLEN_INTUOS, 104280, 65400, 2047, /* Pen */
- 63, WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
+ { "Wacom Cintiq 24HD touch", 104280, 65400, 2047, 63, /* Pen */
+ WACOM_24HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf6 };
static const struct wacom_features wacom_features_0xF6 =
{ "Wacom Cintiq 24HD touch", .type = WACOM_24HDT, /* Touch */
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0xf8, .touch_max = 10,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x3F =
- { "Wacom Cintiq 21UX", WACOM_PKGLEN_INTUOS, 87200, 65600, 1023,
- 63, CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Cintiq 21UX", 87200, 65600, 1023, 63,
+ CINTIQ, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xC5 =
- { "Wacom Cintiq 20WSX", WACOM_PKGLEN_INTUOS, 86680, 54180, 1023,
- 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Cintiq 20WSX", 86680, 54180, 1023, 63,
+ WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0xC6 =
- { "Wacom Cintiq 12WX", WACOM_PKGLEN_INTUOS, 53020, 33440, 1023,
- 63, WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
+ { "Wacom Cintiq 12WX", 53020, 33440, 1023, 63,
+ WACOM_BEE, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES };
static const struct wacom_features wacom_features_0x304 =
- { "Wacom Cintiq 13HD", WACOM_PKGLEN_INTUOS, 59352, 33648, 1023,
- 63, WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
+ { "Wacom Cintiq 13HD", 59352, 33648, 1023, 63,
+ WACOM_13HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
static const struct wacom_features wacom_features_0xC7 =
- { "Wacom DTU1931", WACOM_PKGLEN_GRAPHIRE, 37832, 30305, 511,
- 0, PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom DTU1931", 37832, 30305, 511, 0,
+ PL, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xCE =
- { "Wacom DTU2231", WACOM_PKGLEN_GRAPHIRE, 47864, 27011, 511,
- 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+ { "Wacom DTU2231", 47864, 27011, 511, 0,
+ DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBMOUSE };
static const struct wacom_features wacom_features_0xF0 =
- { "Wacom DTU1631", WACOM_PKGLEN_GRAPHIRE, 34623, 19553, 511,
- 0, DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom DTU1631", 34623, 19553, 511, 0,
+ DTU, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xFB =
- { "Wacom DTU1031", WACOM_PKGLEN_DTUS, 22096, 13960, 511,
- 0, DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom DTU1031", 22096, 13960, 511, 0,
+ DTUS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x57 =
- { "Wacom DTK2241", WACOM_PKGLEN_INTUOS, 95640, 54060, 2047,
- 63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
+ { "Wacom DTK2241", 95640, 54060, 2047, 63,
+ DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
static const struct wacom_features wacom_features_0x59 = /* Pen */
- { "Wacom DTH2242", WACOM_PKGLEN_INTUOS, 95640, 54060, 2047,
- 63, DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
+ { "Wacom DTH2242", 95640, 54060, 2047, 63,
+ DTK, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5D };
static const struct wacom_features wacom_features_0x5D = /* Touch */
{ "Wacom DTH2242", .type = WACOM_24HDT,
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0x59, .touch_max = 10,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0xCC =
- { "Wacom Cintiq 21UX2", WACOM_PKGLEN_INTUOS, 87000, 65400, 2047,
- 63, WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
+ { "Wacom Cintiq 21UX2", 87000, 65400, 2047, 63,
+ WACOM_21UX2, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
static const struct wacom_features wacom_features_0xFA =
- { "Wacom Cintiq 22HD", WACOM_PKGLEN_INTUOS, 95640, 54060, 2047,
- 63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
+ { "Wacom Cintiq 22HD", 95640, 54060, 2047, 63,
+ WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200 };
static const struct wacom_features wacom_features_0x5B =
- { "Wacom Cintiq 22HDT", WACOM_PKGLEN_INTUOS, 95640, 54060, 2047,
- 63, WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
+ { "Wacom Cintiq 22HDT", 95640, 54060, 2047, 63,
+ WACOM_22HD, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5e };
static const struct wacom_features wacom_features_0x5E =
{ "Wacom Cintiq 22HDT", .type = WACOM_24HDT,
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0x5b, .touch_max = 10,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x90 =
- { "Wacom ISDv4 90", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
- 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 90", 26202, 16325, 255, 0,
+ TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x93 =
- { "Wacom ISDv4 93", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
- 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 93", 26202, 16325, 255, 0,
+ TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x97 =
- { "Wacom ISDv4 97", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 511,
- 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 97", 26202, 16325, 511, 0,
+ TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x9A =
- { "Wacom ISDv4 9A", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
- 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 9A", 26202, 16325, 255, 0,
+ TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x9F =
- { "Wacom ISDv4 9F", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
- 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 9F", 26202, 16325, 255, 0,
+ TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xE2 =
- { "Wacom ISDv4 E2", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
- 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom ISDv4 E2", 26202, 16325, 255, 0,
+ TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xE3 =
- { "Wacom ISDv4 E3", WACOM_PKGLEN_TPC2FG, 26202, 16325, 255,
- 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom ISDv4 E3", 26202, 16325, 255, 0,
+ TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xE5 =
- { "Wacom ISDv4 E5", WACOM_PKGLEN_MTOUCH, 26202, 16325, 255,
- 0, MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 E5", 26202, 16325, 255, 0,
+ MTSCREEN, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xE6 =
- { "Wacom ISDv4 E6", WACOM_PKGLEN_TPC2FG, 27760, 15694, 255,
- 0, TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom ISDv4 E6", 27760, 15694, 255, 0,
+ TABLETPC2FG, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xEC =
- { "Wacom ISDv4 EC", WACOM_PKGLEN_GRAPHIRE, 25710, 14500, 255,
- 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 EC", 25710, 14500, 255, 0,
+ TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xED =
- { "Wacom ISDv4 ED", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
- 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 ED", 26202, 16325, 255, 0,
+ TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xEF =
- { "Wacom ISDv4 EF", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
- 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 EF", 26202, 16325, 255, 0,
+ TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x100 =
- { "Wacom ISDv4 100", WACOM_PKGLEN_MTTPC, 26202, 16325, 255,
- 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 100", 26202, 16325, 255, 0,
+ MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x101 =
- { "Wacom ISDv4 101", WACOM_PKGLEN_MTTPC, 26202, 16325, 255,
- 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 101", 26202, 16325, 255, 0,
+ MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x10D =
- { "Wacom ISDv4 10D", WACOM_PKGLEN_MTTPC, 26202, 16325, 255,
- 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 10D", 26202, 16325, 255, 0,
+ MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x10E =
- { "Wacom ISDv4 10E", WACOM_PKGLEN_MTTPC, 27760, 15694, 255,
- 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 10E", 27760, 15694, 255, 0,
+ MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x10F =
- { "Wacom ISDv4 10F", WACOM_PKGLEN_MTTPC, 27760, 15694, 255,
- 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 10F", 27760, 15694, 255, 0,
+ MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x116 =
- { "Wacom ISDv4 116", WACOM_PKGLEN_GRAPHIRE, 26202, 16325, 255,
- 0, TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 116", 26202, 16325, 255, 0,
+ TABLETPCE, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x4001 =
- { "Wacom ISDv4 4001", WACOM_PKGLEN_MTTPC, 26202, 16325, 255,
- 0, MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 4001", 26202, 16325, 255, 0,
+ MTTPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x4004 =
- { "Wacom ISDv4 4004", WACOM_PKGLEN_MTTPC, 11060, 6220, 255,
- 0, MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 4004", 11060, 6220, 255, 0,
+ MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x5000 =
- { "Wacom ISDv4 5000", WACOM_PKGLEN_MTTPC, 27848, 15752, 1023,
- 0, MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 5000", 27848, 15752, 1023, 0,
+ MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x5002 =
- { "Wacom ISDv4 5002", WACOM_PKGLEN_MTTPC, 29576, 16724, 1023,
- 0, MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom ISDv4 5002", 29576, 16724, 1023, 0,
+ MTTPC_B, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x47 =
- { "Wacom Intuos2 6x8", WACOM_PKGLEN_INTUOS, 20320, 16240, 1023,
- 31, INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Intuos2 6x8", 20320, 16240, 1023, 31,
+ INTUOS, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x84 =
- { "Wacom Wireless Receiver", WACOM_PKGLEN_WIRELESS, 0, 0, 0,
- 0, WIRELESS, 0, 0, .touch_max = 16 };
+ { "Wacom Wireless Receiver", 0, 0, 0, 0,
+ WIRELESS, 0, 0, .touch_max = 16 };
static const struct wacom_features wacom_features_0xD0 =
- { "Wacom Bamboo 2FG", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom Bamboo 2FG", 14720, 9200, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xD1 =
- { "Wacom Bamboo 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom Bamboo 2FG 4x5", 14720, 9200, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xD2 =
- { "Wacom Bamboo Craft", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom Bamboo Craft", 14720, 9200, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xD3 =
- { "Wacom Bamboo 2FG 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom Bamboo 2FG 6x8", 21648, 13700, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xD4 =
- { "Wacom Bamboo Pen", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Bamboo Pen", 14720, 9200, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xD5 =
- { "Wacom Bamboo Pen 6x8", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Bamboo Pen 6x8", 21648, 13700, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xD6 =
- { "Wacom BambooPT 2FG 4x5", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom BambooPT 2FG 4x5", 14720, 9200, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xD7 =
- { "Wacom BambooPT 2FG Small", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom BambooPT 2FG Small", 14720, 9200, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xD8 =
- { "Wacom Bamboo Comic 2FG", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom Bamboo Comic 2FG", 21648, 13700, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xDA =
- { "Wacom Bamboo 2FG 4x5 SE", WACOM_PKGLEN_BBFUN, 14720, 9200, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom Bamboo 2FG 4x5 SE", 14720, 9200, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xDB =
- { "Wacom Bamboo 2FG 6x8 SE", WACOM_PKGLEN_BBFUN, 21648, 13700, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 2 };
+ { "Wacom Bamboo 2FG 6x8 SE", 21648, 13700, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 2 };
static const struct wacom_features wacom_features_0xDD =
- { "Wacom Bamboo Connect", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Bamboo Connect", 14720, 9200, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0xDE =
- { "Wacom Bamboo 16FG 4x5", WACOM_PKGLEN_BBPEN, 14720, 9200, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 16 };
+ { "Wacom Bamboo 16FG 4x5", 14720, 9200, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
static const struct wacom_features wacom_features_0xDF =
- { "Wacom Bamboo 16FG 6x8", WACOM_PKGLEN_BBPEN, 21648, 13700, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 16 };
+ { "Wacom Bamboo 16FG 6x8", 21648, 13700, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16 };
static const struct wacom_features wacom_features_0x300 =
- { "Wacom Bamboo One S", WACOM_PKGLEN_BBPEN, 14720, 9225, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Bamboo One S", 14720, 9225, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x301 =
- { "Wacom Bamboo One M", WACOM_PKGLEN_BBPEN, 21648, 13530, 1023,
- 31, BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "Wacom Bamboo One M", 21648, 13530, 1023, 31,
+ BAMBOO_PT, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x302 =
- { "Wacom Intuos PT S", WACOM_PKGLEN_BBPEN, 15200, 9500, 1023,
- 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 16,
+ { "Wacom Intuos PT S", 15200, 9500, 1023, 31,
+ INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x303 =
- { "Wacom Intuos PT M", WACOM_PKGLEN_BBPEN, 21600, 13500, 1023,
- 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
- .touch_max = 16,
+ { "Wacom Intuos PT M", 21600, 13500, 1023, 31,
+ INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES, .touch_max = 16,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x30E =
- { "Wacom Intuos S", WACOM_PKGLEN_BBPEN, 15200, 9500, 1023,
- 31, INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
+ { "Wacom Intuos S", 15200, 9500, 1023, 31,
+ INTUOSHT, WACOM_INTUOS_RES, WACOM_INTUOS_RES,
.check_for_hid_type = true, .hid_type = HID_TYPE_USBNONE };
static const struct wacom_features wacom_features_0x6004 =
- { "ISD-V4", WACOM_PKGLEN_GRAPHIRE, 12800, 8000, 255,
- 0, TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
+ { "ISD-V4", 12800, 8000, 255, 0,
+ TABLETPC, WACOM_INTUOS_RES, WACOM_INTUOS_RES };
static const struct wacom_features wacom_features_0x0307 =
- { "Wacom ISDv5 307", WACOM_PKGLEN_INTUOS, 59352, 33648, 2047,
- 63, CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
+ { "Wacom ISDv5 307", 59352, 33648, 2047, 63,
+ CINTIQ_HYBRID, WACOM_INTUOS3_RES, WACOM_INTUOS3_RES, 200, 200,
.oVid = USB_VENDOR_ID_WACOM, .oPid = 0x309 };
static const struct wacom_features wacom_features_0x0309 =
{ "Wacom ISDv5 309", .type = WACOM_24HDT, /* Touch */
diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 2a7612a..4c59247 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -114,7 +114,6 @@ enum {

struct wacom_features {
const char *name;
- int pktlen;
int x_max;
int y_max;
int pressure_max;
@@ -137,6 +136,7 @@ struct wacom_features {
unsigned touch_max;
int oVid;
int oPid;
+ int pktlen;
bool check_for_hid_type;
int hid_type;
};
--
2.0.0

2014-06-30 21:26:58

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 09/15] Input - wacom: register power device at the HID level

Use the HID device as the parent for the power device when dealing with
a wireless receiver.
Removes one more usb dependency and does not break user space.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 6fe7a6c..2313f1a 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -969,12 +969,12 @@ static int wacom_initialize_battery(struct wacom *wacom)
wacom->battery.type = POWER_SUPPLY_TYPE_BATTERY;
wacom->battery.use_for_apm = 0;

- error = power_supply_register(&wacom->usbdev->dev,
+ error = power_supply_register(&wacom->hdev->dev,
&wacom->battery);

if (!error)
power_supply_powers(&wacom->battery,
- &wacom->usbdev->dev);
+ &wacom->hdev->dev);
}

return error;
--
2.0.0

2014-06-30 21:28:08

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 12/15] Input - wacom: use in-kernel HID parser

HID already parses the report descriptor, so use it instead of implementing
our own.
The special case for Bamboo PT 3rd gen is also removed and handled in the
same way Intuos 5 is treated, by hardcoding it in the driver.
Last, the unit_exponent stored into the hid field already is signed, so
there is no need to handle a two's complement anymore.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 344 +++++++++++++--------------------------
drivers/input/tablet/wacom_wac.h | 4 +-
2 files changed, 112 insertions(+), 236 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 065c6d5..eab299c 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -15,13 +15,6 @@
#include "wacom.h"
#include <linux/hid.h>

-#define HID_HDESC_USAGE_UNDEFINED 0x00
-#define HID_HDESC_USAGE_PAGE 0x05
-#define HID_HDESC_USAGE 0x09
-#define HID_HDESC_COLLECTION 0xa1
-#define HID_HDESC_COLLECTION_LOGICAL 0x02
-#define HID_HDESC_COLLECTION_END 0xc0
-
#define WAC_MSG_RETRIES 5

#define WAC_CMD_LED_CONTROL 0x20
@@ -96,19 +89,15 @@ static void wacom_close(struct input_dev *dev)
* This function is little more than hidinput_calc_abs_res stripped down.
*/
static int wacom_calc_hid_res(int logical_extents, int physical_extents,
- unsigned char unit, unsigned char exponent)
+ unsigned unit, int exponent)
{
- int prev, unit_exponent;
+ int prev;
+ int unit_exponent = exponent;

/* Check if the extents are sane */
if (logical_extents <= 0 || physical_extents <= 0)
return 0;

- /* Get signed value of nybble-sized twos-compliment exponent */
- unit_exponent = exponent;
- if (unit_exponent > 7)
- unit_exponent -= 16;
-
/* Convert physical_extents to millimeters */
if (unit == 0x11) { /* If centimeters */
unit_exponent += 1;
@@ -141,42 +130,18 @@ static int wacom_calc_hid_res(int logical_extents, int physical_extents,
return logical_extents / physical_extents;
}

-static int wacom_parse_logical_collection(unsigned char *report,
- struct wacom_features *features)
-{
- int length = 0;
-
- if (features->type == BAMBOO_PT) {
-
- /* Logical collection is only used by 3rd gen Bamboo Touch */
- features->device_type = BTN_TOOL_FINGER;
-
- features->x_max = features->y_max =
- get_unaligned_le16(&report[10]);
-
- length = 11;
- }
- return length;
-}
-
-static void wacom_retrieve_report_data(struct hid_device *hdev,
- struct wacom_features *features)
+static void wacom_feature_mapping(struct hid_device *hdev,
+ struct hid_field *field, struct hid_usage *usage)
{
- int result = 0;
- unsigned char *rep_data;
-
- rep_data = kmalloc(2, GFP_KERNEL);
- if (rep_data) {
-
- rep_data[0] = 12;
- result = wacom_get_report(hdev, HID_FEATURE_REPORT,
- rep_data[0], rep_data, 2,
- WAC_MSG_RETRIES);
-
- if (result >= 0 && rep_data[1] > 2)
- features->touch_max = rep_data[1];
+ struct wacom *wacom = hid_get_drvdata(hdev);
+ struct wacom_features *features = &wacom->wacom_wac.features;

- kfree(rep_data);
+ switch (usage->hid) {
+ case HID_DG_CONTACTMAX:
+ /* leave touch_max as is if predefined */
+ if (!features->touch_max)
+ features->touch_max = field->value[0];
+ break;
}
}

@@ -209,190 +174,96 @@ static void wacom_retrieve_report_data(struct hid_device *hdev,
* interfaces haven't supported pressure or distance, this is enough
* information to override invalid values in the wacom_features table.
*
- * 3rd gen Bamboo Touch no longer define a Digitizer-Finger Pysical
- * Collection. Instead they define a Logical Collection with a single
- * Logical Maximum for both X and Y.
- *
- * Intuos5 touch interface does not contain useful data. We deal with
- * this after returning from this function.
+ * Intuos5 touch interface and 3rd gen Bamboo Touch do not contain useful
+ * data. We deal with them after returning from this function.
*/
-static int wacom_parse_hid(struct hid_device *hdev,
- struct wacom_features *features)
+static void wacom_usage_mapping(struct hid_device *hdev,
+ struct hid_field *field, struct hid_usage *usage)
{
- /* result has to be defined as int for some devices */
- int result = 0, touch_max = 0;
- int i = 0, page = 0, finger = 0, pen = 0;
- unsigned char *report = hdev->rdesc;
-
- for (i = 0; i < hdev->rsize; i++) {
-
- switch (report[i]) {
- case HID_HDESC_USAGE_PAGE:
- page = report[i + 1];
- i++;
- break;
-
- case HID_HDESC_USAGE:
- switch (page << 16 | report[i + 1]) {
- case HID_GD_X:
- if (finger) {
- features->device_type = BTN_TOOL_FINGER;
- /* touch device at least supports one touch point */
- touch_max = 1;
-
- switch (features->type) {
- case BAMBOO_PT:
- features->x_phy =
- get_unaligned_le16(&report[i + 5]);
- features->x_max =
- get_unaligned_le16(&report[i + 8]);
- i += 15;
- break;
-
- case WACOM_24HDT:
- features->x_max =
- get_unaligned_le16(&report[i + 3]);
- features->x_phy =
- get_unaligned_le16(&report[i + 8]);
- features->unit = report[i - 1];
- features->unitExpo = report[i - 3];
- i += 12;
- break;
-
- case MTTPC_B:
- features->x_max =
- get_unaligned_le16(&report[i + 3]);
- features->x_phy =
- get_unaligned_le16(&report[i + 6]);
- features->unit = report[i - 5];
- features->unitExpo = report[i - 3];
- i += 9;
- break;
-
- default:
- features->x_max =
- get_unaligned_le16(&report[i + 3]);
- features->x_phy =
- get_unaligned_le16(&report[i + 6]);
- features->unit = report[i + 9];
- features->unitExpo = report[i + 11];
- i += 12;
- break;
- }
- } else if (pen) {
- /* penabled only accepts exact bytes of data */
- features->device_type = BTN_TOOL_PEN;
- features->x_max =
- get_unaligned_le16(&report[i + 3]);
- i += 4;
- }
- break;
-
- case HID_GD_Y:
- if (finger) {
- switch (features->type) {
- case TABLETPC2FG:
- case MTSCREEN:
- case MTTPC:
- features->y_max =
- get_unaligned_le16(&report[i + 3]);
- features->y_phy =
- get_unaligned_le16(&report[i + 6]);
- i += 7;
- break;
-
- case WACOM_24HDT:
- features->y_max =
- get_unaligned_le16(&report[i + 3]);
- features->y_phy =
- get_unaligned_le16(&report[i - 2]);
- i += 7;
- break;
-
- case BAMBOO_PT:
- features->y_phy =
- get_unaligned_le16(&report[i + 3]);
- features->y_max =
- get_unaligned_le16(&report[i + 6]);
- i += 12;
- break;
-
- case MTTPC_B:
- features->y_max =
- get_unaligned_le16(&report[i + 3]);
- features->y_phy =
- get_unaligned_le16(&report[i + 6]);
- i += 9;
- break;
-
- default:
- features->y_max =
- features->x_max;
- features->y_phy =
- get_unaligned_le16(&report[i + 3]);
- i += 4;
- break;
- }
- } else if (pen) {
- features->y_max =
- get_unaligned_le16(&report[i + 3]);
- i += 4;
- }
- break;
-
- case HID_DG_FINGER:
- finger = 1;
- i++;
- break;
+ struct wacom *wacom = hid_get_drvdata(hdev);
+ struct wacom_features *features = &wacom->wacom_wac.features;
+ bool finger = (field->logical == HID_DG_FINGER) ||
+ (field->physical == HID_DG_FINGER);
+ bool pen = (field->logical == HID_DG_STYLUS) ||
+ (field->physical == HID_DG_STYLUS);

- /*
- * Requiring Stylus Usage will ignore boot mouse
- * X/Y values and some cases of invalid Digitizer X/Y
- * values commonly reported.
- */
- case HID_DG_STYLUS:
- pen = 1;
- i++;
- break;
+ /*
+ * Requiring Stylus Usage will ignore boot mouse
+ * X/Y values and some cases of invalid Digitizer X/Y
+ * values commonly reported.
+ */
+ if (!pen && !finger)
+ return;

- case HID_DG_CONTACTMAX:
- /* leave touch_max as is if predefined */
- if (!features->touch_max)
- wacom_retrieve_report_data(hdev, features);
- i++;
- break;
+ if (finger && !features->touch_max)
+ /* touch device at least supports one touch point */
+ features->touch_max = 1;

- case HID_DG_TIPPRESSURE:
- if (pen) {
- features->pressure_max =
- get_unaligned_le16(&report[i + 3]);
- i += 4;
- }
- break;
+ switch (usage->hid) {
+ case HID_GD_X:
+ features->x_max = field->logical_maximum;
+ if (finger) {
+ features->device_type = BTN_TOOL_FINGER;
+ features->x_phy = field->physical_maximum;
+ if (features->type != BAMBOO_PT) {
+ features->unit = field->unit;
+ features->unitExpo = field->unit_exponent;
}
- break;
-
- case HID_HDESC_COLLECTION_END:
- /* reset UsagePage and Finger */
- finger = page = 0;
- break;
+ } else {
+ features->device_type = BTN_TOOL_PEN;
+ }
+ break;
+ case HID_GD_Y:
+ features->y_max = field->logical_maximum;
+ if (finger) {
+ features->y_phy = field->physical_maximum;
+ if (features->type != BAMBOO_PT) {
+ features->unit = field->unit;
+ features->unitExpo = field->unit_exponent;
+ }
+ }
+ break;
+ case HID_DG_TIPPRESSURE:
+ if (pen)
+ features->pressure_max = field->logical_maximum;
+ break;
+ }
+}

- case HID_HDESC_COLLECTION:
- i++;
- switch (report[i]) {
- case HID_HDESC_COLLECTION_LOGICAL:
- i += wacom_parse_logical_collection(&report[i],
- features);
- break;
+static void wacom_parse_hid(struct hid_device *hdev,
+ struct wacom_features *features)
+{
+ struct hid_report_enum *rep_enum;
+ struct hid_report *hreport;
+ int i, j;
+
+ /* check features first */
+ rep_enum = &hdev->report_enum[HID_FEATURE_REPORT];
+ list_for_each_entry(hreport, &rep_enum->report_list, list) {
+ for (i = 0; i < hreport->maxfield; i++) {
+ /* Ignore if report count is out of bounds. */
+ if (hreport->field[i]->report_count < 1)
+ continue;
+
+ for (j = 0; j < hreport->field[i]->maxusage; j++) {
+ wacom_feature_mapping(hdev, hreport->field[i],
+ hreport->field[i]->usage + j);
}
- break;
}
}

- if (!features->touch_max && touch_max)
- features->touch_max = touch_max;
- result = 0;
- return result;
+ /* now check the input usages */
+ rep_enum = &hdev->report_enum[HID_INPUT_REPORT];
+ list_for_each_entry(hreport, &rep_enum->report_list, list) {
+
+ if (!hreport->maxfield)
+ continue;
+
+ for (i = 0; i < hreport->maxfield; i++)
+ for (j = 0; j < hreport->field[i]->maxusage; j++)
+ wacom_usage_mapping(hdev, hreport->field[i],
+ hreport->field[i]->usage + j);
+ }
}

static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
@@ -448,10 +319,9 @@ static int wacom_query_tablet_data(struct hid_device *hdev,
return 0;
}

-static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
+static void wacom_retrieve_hid_descriptor(struct hid_device *hdev,
struct wacom_features *features)
{
- int error = 0;
struct wacom *wacom = hid_get_drvdata(hdev);
struct usb_interface *intf = wacom->intf;

@@ -478,14 +348,10 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
}

/* only devices that support touch need to retrieve the info */
- if (features->type < BAMBOO_PT) {
- goto out;
- }
-
- error = wacom_parse_hid(hdev, features);
+ if (features->type < BAMBOO_PT)
+ return;

- out:
- return error;
+ wacom_parse_hid(hdev, features);
}

struct wacom_hdev_data {
@@ -1276,9 +1142,7 @@ static int wacom_probe(struct hid_device *hdev,
wacom_set_default_phy(features);

/* Retrieve the physical and logical size for touch devices */
- error = wacom_retrieve_hid_descriptor(hdev, features);
- if (error)
- goto fail1;
+ wacom_retrieve_hid_descriptor(hdev, features);

/*
* Intuos5 has no useful data about its touch interface in its
@@ -1296,12 +1160,24 @@ static int wacom_probe(struct hid_device *hdev,
}
}

+ /*
+ * Same thing for Bamboo 3rd gen.
+ */
+ if ((features->type == BAMBOO_PT) &&
+ (features->pktlen == WACOM_PKGLEN_BBTOUCH3) &&
+ (features->device_type == BTN_TOOL_PEN)) {
+ features->device_type = BTN_TOOL_FINGER;
+
+ features->x_max = 4096;
+ features->y_max = 4096;
+ }
+
wacom_setup_device_quirks(features);

/* set unit to "100th of a mm" for devices not reported by HID */
if (!features->unit) {
features->unit = 0x11;
- features->unitExpo = 16 - 3;
+ features->unitExpo = -3;
}
wacom_calculate_res(features);

diff --git a/drivers/input/tablet/wacom_wac.h b/drivers/input/tablet/wacom_wac.h
index 8821a51..2a7612a 100644
--- a/drivers/input/tablet/wacom_wac.h
+++ b/drivers/input/tablet/wacom_wac.h
@@ -127,8 +127,8 @@ struct wacom_features {
int device_type;
int x_phy;
int y_phy;
- unsigned char unit;
- unsigned char unitExpo;
+ unsigned unit;
+ int unitExpo;
int x_fuzz;
int y_fuzz;
int pressure_fuzz;
--
2.0.0

2014-06-30 21:28:40

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 11/15] HID: uhid: add and set HID_TYPE_UHID for uhid devices

Some wacom devices checks on the .type field of hid_device. However,
uhid never set it, and as a result, we can not use uhid with some of
the wacom tablets.

Create a HID type HID_TYPE_UHID which is set by uhid and taken into
account by wacom.ko.

With this patch, the wacom.ko driver is completely agnostic of the
USB layer, except for the Wireless Receiver. That means that starting
from now, we can check every changes through uhis and comparing the
resulting kernel device.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/hid/uhid.c | 2 ++
drivers/input/tablet/wacom_sys.c | 3 ++-
include/linux/hid.h | 3 ++-
3 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/hid/uhid.c b/drivers/hid/uhid.c
index 0cb92e3..6dbe2e0 100644
--- a/drivers/hid/uhid.c
+++ b/drivers/hid/uhid.c
@@ -407,6 +407,7 @@ static int uhid_dev_create(struct uhid_device *uhid,
hid->country = ev->u.create.country;
hid->driver_data = uhid;
hid->dev.parent = uhid_misc.this_device;
+ hid->type = HID_TYPE_UHID;

uhid->hid = hid;
uhid->running = true;
@@ -467,6 +468,7 @@ static int uhid_dev_create2(struct uhid_device *uhid,
hid->country = ev->u.create2.country;
hid->driver_data = uhid;
hid->dev.parent = uhid_misc.this_device;
+ hid->type = HID_TYPE_UHID;

uhid->hid = hid;
uhid->running = true;
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 2208b4a..065c6d5 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -1261,7 +1261,8 @@ static int wacom_probe(struct hid_device *hdev,
goto fail1;
}

- if (features->check_for_hid_type && features->hid_type != hdev->type) {
+ if (hdev->type != HID_TYPE_UHID &&
+ features->check_for_hid_type && features->hid_type != hdev->type) {
error = -ENODEV;
goto fail1;
}
diff --git a/include/linux/hid.h b/include/linux/hid.h
index 9732299..df3c103 100644
--- a/include/linux/hid.h
+++ b/include/linux/hid.h
@@ -448,7 +448,8 @@ struct hid_input {
enum hid_type {
HID_TYPE_OTHER = 0,
HID_TYPE_USBMOUSE,
- HID_TYPE_USBNONE
+ HID_TYPE_USBNONE,
+ HID_TYPE_UHID
};

struct hid_driver;
--
2.0.0

2014-06-30 21:29:23

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 06/15] Input - wacom: install LED/OLED sysfs files in the HID device instead of USB

Removes one more dependency over USB, but requires some changes in
the user space to find the sysfs files correctly.

This patch breaks the user space. However, the number of program
accessing the LEDs is quite limited and we can easily patch them
to handle the new HID behavior.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 3f1cee6..6f4bf6d 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -675,7 +675,7 @@ out:
static ssize_t wacom_led_select_store(struct device *dev, int set_id,
const char *buf, size_t count)
{
- struct hid_device *hdev = dev_get_drvdata(dev);
+ struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct wacom *wacom = hid_get_drvdata(hdev);
unsigned int id;
int err;
@@ -703,7 +703,7 @@ static ssize_t wacom_led##SET_ID##_select_store(struct device *dev, \
static ssize_t wacom_led##SET_ID##_select_show(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
- struct hid_device *hdev = dev_get_drvdata(dev); \
+ struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
struct wacom *wacom = hid_get_drvdata(hdev); \
return snprintf(buf, 2, "%d\n", wacom->led.select[SET_ID]); \
} \
@@ -738,7 +738,7 @@ static ssize_t wacom_luminance_store(struct wacom *wacom, u8 *dest,
static ssize_t wacom_##name##_luminance_store(struct device *dev, \
struct device_attribute *attr, const char *buf, size_t count) \
{ \
- struct hid_device *hdev = dev_get_drvdata(dev); \
+ struct hid_device *hdev = container_of(dev, struct hid_device, dev);\
struct wacom *wacom = hid_get_drvdata(hdev); \
\
return wacom_luminance_store(wacom, &wacom->led.field, \
@@ -754,7 +754,7 @@ DEVICE_LUMINANCE_ATTR(buttons, img_lum);
static ssize_t wacom_button_image_store(struct device *dev, int button_id,
const char *buf, size_t count)
{
- struct hid_device *hdev = dev_get_drvdata(dev);
+ struct hid_device *hdev = container_of(dev, struct hid_device, dev);
struct wacom *wacom = hid_get_drvdata(hdev);
int err;

@@ -845,7 +845,7 @@ static int wacom_initialize_leds(struct wacom *wacom)
wacom->led.llv = 10;
wacom->led.hlv = 20;
wacom->led.img_lum = 10;
- error = sysfs_create_group(&wacom->intf->dev.kobj,
+ error = sysfs_create_group(&wacom->hdev->dev.kobj,
&intuos4_led_attr_group);
break;

@@ -857,7 +857,7 @@ static int wacom_initialize_leds(struct wacom *wacom)
wacom->led.hlv = 0;
wacom->led.img_lum = 0;

- error = sysfs_create_group(&wacom->intf->dev.kobj,
+ error = sysfs_create_group(&wacom->hdev->dev.kobj,
&cintiq_led_attr_group);
break;

@@ -874,7 +874,7 @@ static int wacom_initialize_leds(struct wacom *wacom)
wacom->led.hlv = 0;
wacom->led.img_lum = 0;

- error = sysfs_create_group(&wacom->intf->dev.kobj,
+ error = sysfs_create_group(&wacom->hdev->dev.kobj,
&intuos5_led_attr_group);
} else
return 0;
@@ -885,7 +885,7 @@ static int wacom_initialize_leds(struct wacom *wacom)
}

if (error) {
- dev_err(&wacom->intf->dev,
+ hid_err(wacom->hdev,
"cannot create sysfs group err: %d\n", error);
return error;
}
@@ -906,13 +906,13 @@ static void wacom_destroy_leds(struct wacom *wacom)
case INTUOS4S:
case INTUOS4:
case INTUOS4L:
- sysfs_remove_group(&wacom->intf->dev.kobj,
+ sysfs_remove_group(&wacom->hdev->dev.kobj,
&intuos4_led_attr_group);
break;

case WACOM_24HD:
case WACOM_21UX2:
- sysfs_remove_group(&wacom->intf->dev.kobj,
+ sysfs_remove_group(&wacom->hdev->dev.kobj,
&cintiq_led_attr_group);
break;

@@ -923,7 +923,7 @@ static void wacom_destroy_leds(struct wacom *wacom)
case INTUOSPM:
case INTUOSPL:
if (wacom->wacom_wac.features.device_type == BTN_TOOL_PEN)
- sysfs_remove_group(&wacom->intf->dev.kobj,
+ sysfs_remove_group(&wacom->hdev->dev.kobj,
&intuos5_led_attr_group);
break;
}
--
2.0.0

2014-06-30 21:29:22

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 07/15] Input - wacom: register the input devices on top of the HID one

Matches the current behavior of the HID subsystem and removes one more
dependency over USB.

The current user space clients which relies on this to fetch the
LEDs path need an update. However, we already break them in the
kernel v3.11 for the Bluetooth Wacom devices. They are going to be fixed
soon.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom.h | 1 -
drivers/input/tablet/wacom_sys.c | 15 ++++++++-------
2 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/input/tablet/wacom.h b/drivers/input/tablet/wacom.h
index a931221..a678f82 100644
--- a/drivers/input/tablet/wacom.h
+++ b/drivers/input/tablet/wacom.h
@@ -112,7 +112,6 @@ struct wacom {
struct hid_device *hdev;
struct mutex lock;
struct work_struct work;
- char phys[32];
struct wacom_led {
u8 select[2]; /* status led selector (0..3) */
u8 llv; /* status led brightness no button (1..127) */
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 6f4bf6d..0d0397d 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -992,8 +992,7 @@ static void wacom_destroy_battery(struct wacom *wacom)
static struct input_dev *wacom_allocate_input(struct wacom *wacom)
{
struct input_dev *input_dev;
- struct usb_interface *intf = wacom->intf;
- struct usb_device *dev = interface_to_usbdev(intf);
+ struct hid_device *hdev = wacom->hdev;
struct wacom_wac *wacom_wac = &(wacom->wacom_wac);

input_dev = input_allocate_device();
@@ -1001,11 +1000,15 @@ static struct input_dev *wacom_allocate_input(struct wacom *wacom)
return NULL;

input_dev->name = wacom_wac->name;
- input_dev->phys = wacom->phys;
- input_dev->dev.parent = &intf->dev;
+ input_dev->phys = hdev->phys;
+ input_dev->dev.parent = &hdev->dev;
input_dev->open = wacom_open;
input_dev->close = wacom_close;
- usb_to_input_id(dev, &input_dev->id);
+ input_dev->uniq = hdev->uniq;
+ input_dev->id.bustype = hdev->bus;
+ input_dev->id.vendor = hdev->vendor;
+ input_dev->id.product = hdev->product;
+ input_dev->id.version = hdev->version;
input_set_drvdata(input_dev, wacom);

return input_dev;
@@ -1269,8 +1272,6 @@ static int wacom_probe(struct hid_device *hdev,
wacom->intf = intf;
mutex_init(&wacom->lock);
INIT_WORK(&wacom->work, wacom_wireless_work);
- usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
- strlcat(wacom->phys, "/input0", sizeof(wacom->phys));

/* set the default size in case we do not get them from hid */
wacom_set_default_phy(features);
--
2.0.0

2014-06-30 21:26:48

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 03/15] Input - wacom: use hid communication instead of plain usb

Wacom.ko was a plain USB driver for a HID device. The communications
from/to the devices can actually be replaced with the HID API.

At the USB level, the reports are exactly the same.

This will allow to use uhid virtual devices instead of true USB devices.
This step is necessary to implement regression tests.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 81 ++++++++++++++++++----------------------
1 file changed, 36 insertions(+), 45 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index aa2a4d7..eb39314 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -34,11 +34,6 @@ struct wac_hid_descriptor {
__le16 wDescriptorLength;
} __attribute__ ((packed));

-/* defines to get/set USB message */
-#define USB_REQ_GET_REPORT 0x01
-#define USB_REQ_SET_REPORT 0x09
-
-#define WAC_HID_FEATURE_REPORT 0x03
#define WAC_MSG_RETRIES 5

#define WAC_CMD_LED_CONTROL 0x20
@@ -46,38 +41,27 @@ struct wac_hid_descriptor {
#define WAC_CMD_ICON_XFER 0x23
#define WAC_CMD_RETRIES 10

-static int wacom_get_report(struct usb_interface *intf, u8 type, u8 id,
+static int wacom_get_report(struct hid_device *hdev, u8 type, u8 id,
void *buf, size_t size, unsigned int retries)
{
- struct usb_device *dev = interface_to_usbdev(intf);
int retval;

do {
- retval = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
- USB_REQ_GET_REPORT,
- USB_DIR_IN | USB_TYPE_CLASS |
- USB_RECIP_INTERFACE,
- (type << 8) + id,
- intf->altsetting[0].desc.bInterfaceNumber,
- buf, size, 100);
+ retval = hid_hw_raw_request(hdev, id, buf, size, type,
+ HID_REQ_GET_REPORT);
} while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);

return retval;
}

-static int wacom_set_report(struct usb_interface *intf, u8 type, u8 id,
+static int wacom_set_report(struct hid_device *hdev, u8 type, u8 id,
void *buf, size_t size, unsigned int retries)
{
- struct usb_device *dev = interface_to_usbdev(intf);
int retval;

do {
- retval = usb_control_msg(dev, usb_sndctrlpipe(dev, 0),
- USB_REQ_SET_REPORT,
- USB_TYPE_CLASS | USB_RECIP_INTERFACE,
- (type << 8) + id,
- intf->altsetting[0].desc.bInterfaceNumber,
- buf, size, 1000);
+ retval = hid_hw_raw_request(hdev, id, buf, size, type,
+ HID_REQ_SET_REPORT);
} while ((retval == -ETIMEDOUT || retval == -EPIPE) && --retries);

return retval;
@@ -188,7 +172,7 @@ static int wacom_parse_logical_collection(unsigned char *report,
return length;
}

-static void wacom_retrieve_report_data(struct usb_interface *intf,
+static void wacom_retrieve_report_data(struct hid_device *hdev,
struct wacom_features *features)
{
int result = 0;
@@ -198,7 +182,7 @@ static void wacom_retrieve_report_data(struct usb_interface *intf,
if (rep_data) {

rep_data[0] = 12;
- result = wacom_get_report(intf, WAC_HID_FEATURE_REPORT,
+ result = wacom_get_report(hdev, HID_FEATURE_REPORT,
rep_data[0], rep_data, 2,
WAC_MSG_RETRIES);

@@ -245,10 +229,12 @@ static void wacom_retrieve_report_data(struct usb_interface *intf,
* Intuos5 touch interface does not contain useful data. We deal with
* this after returning from this function.
*/
-static int wacom_parse_hid(struct usb_interface *intf,
+static int wacom_parse_hid(struct hid_device *hdev,
struct wac_hid_descriptor *hid_desc,
struct wacom_features *features)
{
+ struct wacom *wacom = hid_get_drvdata(hdev);
+ struct usb_interface *intf = wacom->intf;
struct usb_device *dev = interface_to_usbdev(intf);
char limit = 0;
/* result has to be defined as int for some devices */
@@ -435,7 +421,7 @@ static int wacom_parse_hid(struct usb_interface *intf,
case HID_DG_CONTACTMAX:
/* leave touch_max as is if predefined */
if (!features->touch_max)
- wacom_retrieve_report_data(intf, features);
+ wacom_retrieve_report_data(hdev, features);
i++;
break;

@@ -474,7 +460,8 @@ static int wacom_parse_hid(struct usb_interface *intf,
return result;
}

-static int wacom_set_device_mode(struct usb_interface *intf, int report_id, int length, int mode)
+static int wacom_set_device_mode(struct hid_device *hdev, int report_id,
+ int length, int mode)
{
unsigned char *rep_data;
int error = -ENOMEM, limit = 0;
@@ -487,10 +474,10 @@ static int wacom_set_device_mode(struct usb_interface *intf, int report_id, int
rep_data[0] = report_id;
rep_data[1] = mode;

- error = wacom_set_report(intf, WAC_HID_FEATURE_REPORT,
+ error = wacom_set_report(hdev, HID_FEATURE_REPORT,
report_id, rep_data, length, 1);
if (error >= 0)
- error = wacom_get_report(intf, WAC_HID_FEATURE_REPORT,
+ error = wacom_get_report(hdev, HID_FEATURE_REPORT,
report_id, rep_data, length, 1);
} while ((error < 0 || rep_data[1] != mode) && limit++ < WAC_MSG_RETRIES);

@@ -506,29 +493,32 @@ static int wacom_set_device_mode(struct usb_interface *intf, int report_id, int
* from the tablet, it is necessary to switch the tablet out of this
* mode and into one which sends the full range of tablet data.
*/
-static int wacom_query_tablet_data(struct usb_interface *intf, struct wacom_features *features)
+static int wacom_query_tablet_data(struct hid_device *hdev,
+ struct wacom_features *features)
{
if (features->device_type == BTN_TOOL_FINGER) {
if (features->type > TABLETPC) {
/* MT Tablet PC touch */
- return wacom_set_device_mode(intf, 3, 4, 4);
+ return wacom_set_device_mode(hdev, 3, 4, 4);
}
else if (features->type == WACOM_24HDT || features->type == CINTIQ_HYBRID) {
- return wacom_set_device_mode(intf, 18, 3, 2);
+ return wacom_set_device_mode(hdev, 18, 3, 2);
}
} else if (features->device_type == BTN_TOOL_PEN) {
if (features->type <= BAMBOO_PT && features->type != WIRELESS) {
- return wacom_set_device_mode(intf, 2, 2, 2);
+ return wacom_set_device_mode(hdev, 2, 2, 2);
}
}

return 0;
}

-static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
+static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
struct wacom_features *features)
{
int error = 0;
+ struct wacom *wacom = hid_get_drvdata(hdev);
+ struct usb_interface *intf = wacom->intf;
struct usb_host_interface *interface = intf->cur_altsetting;
struct wac_hid_descriptor *hid_desc;

@@ -564,12 +554,12 @@ static int wacom_retrieve_hid_descriptor(struct usb_interface *intf,
error = usb_get_extra_descriptor(&interface->endpoint[0],
HID_DEVICET_REPORT, &hid_desc);
if (error) {
- dev_err(&intf->dev,
+ hid_err(hdev,
"can not retrieve extra class descriptor\n");
goto out;
}
}
- error = wacom_parse_hid(intf, hid_desc, features);
+ error = wacom_parse_hid(hdev, hid_desc, features);

out:
return error;
@@ -711,8 +701,8 @@ static int wacom_led_control(struct wacom *wacom)
buf[4] = wacom->led.img_lum;
}

- retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_LED_CONTROL,
- buf, 9, WAC_CMD_RETRIES);
+ retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT,
+ WAC_CMD_LED_CONTROL, buf, 9, WAC_CMD_RETRIES);
kfree(buf);

return retval;
@@ -730,8 +720,8 @@ static int wacom_led_putimage(struct wacom *wacom, int button_id, const void *im
/* Send 'start' command */
buf[0] = WAC_CMD_ICON_START;
buf[1] = 1;
- retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START,
- buf, 2, WAC_CMD_RETRIES);
+ retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT,
+ WAC_CMD_ICON_START, buf, 2, WAC_CMD_RETRIES);
if (retval < 0)
goto out;

@@ -741,7 +731,8 @@ static int wacom_led_putimage(struct wacom *wacom, int button_id, const void *im
buf[2] = i;
memcpy(buf + 3, img + i * 256, 256);

- retval = wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_XFER,
+ retval = wacom_set_report(wacom->hdev, HID_FEATURE_REPORT,
+ WAC_CMD_ICON_XFER,
buf, 259, WAC_CMD_RETRIES);
if (retval < 0)
break;
@@ -750,7 +741,7 @@ static int wacom_led_putimage(struct wacom *wacom, int button_id, const void *im
/* Send 'stop' */
buf[0] = WAC_CMD_ICON_START;
buf[1] = 0;
- wacom_set_report(wacom->intf, 0x03, WAC_CMD_ICON_START,
+ wacom_set_report(wacom->hdev, HID_FEATURE_REPORT, WAC_CMD_ICON_START,
buf, 2, WAC_CMD_RETRIES);

out:
@@ -1334,7 +1325,7 @@ static int wacom_probe(struct hid_device *hdev,
wacom_set_default_phy(features);

/* Retrieve the physical and logical size for touch devices */
- error = wacom_retrieve_hid_descriptor(intf, features);
+ error = wacom_retrieve_hid_descriptor(hdev, features);
if (error)
goto fail1;

@@ -1398,7 +1389,7 @@ static int wacom_probe(struct hid_device *hdev,
}

/* Note that if query fails it is not a hard failure */
- wacom_query_tablet_data(intf, features);
+ wacom_query_tablet_data(hdev, features);

/* Regular HID work starts now */
error = hid_parse(hdev);
@@ -1459,7 +1450,7 @@ static int wacom_resume(struct hid_device *hdev)
mutex_lock(&wacom->lock);

/* switch to wacom mode first */
- wacom_query_tablet_data(wacom->intf, features);
+ wacom_query_tablet_data(hdev, features);
wacom_led_control(wacom);

mutex_unlock(&wacom->lock);
--
2.0.0

2014-06-30 21:30:00

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 05/15] Input - wacom: compute the HID report size to get the actual packet size

This removes an USB dependency and is more accurate: the computed pktlen
is the actual maximum size of the reports forwarded by the device.

Given that the pktlen is correctly computed/validated, we can store it now
in the features struct instead of having a special handling in the rest of
the code.

Likewise, this information is not mandatory anymore in the description
of devices in wacom_wac.c. They will be removed in a separate patch.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 58 ++++++++++++++++++----------------------
1 file changed, 26 insertions(+), 32 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index cd3d936..3f1cee6 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -149,7 +149,6 @@ static int wacom_parse_logical_collection(unsigned char *report,
if (features->type == BAMBOO_PT) {

/* Logical collection is only used by 3rd gen Bamboo Touch */
- features->pktlen = WACOM_PKGLEN_BBTOUCH3;
features->device_type = BTN_TOOL_FINGER;

features->x_max = features->y_max =
@@ -240,29 +239,6 @@ static int wacom_parse_hid(struct hid_device *hdev,
features->device_type = BTN_TOOL_FINGER;
/* touch device at least supports one touch point */
touch_max = 1;
- switch (features->type) {
- case TABLETPC2FG:
- features->pktlen = WACOM_PKGLEN_TPC2FG;
- break;
-
- case MTSCREEN:
- case WACOM_24HDT:
- features->pktlen = WACOM_PKGLEN_MTOUCH;
- break;
-
- case MTTPC:
- case MTTPC_B:
- features->pktlen = WACOM_PKGLEN_MTTPC;
- break;
-
- case BAMBOO_PT:
- features->pktlen = WACOM_PKGLEN_BBTOUCH;
- break;
-
- default:
- features->pktlen = WACOM_PKGLEN_GRAPHIRE;
- break;
- }

switch (features->type) {
case BAMBOO_PT:
@@ -305,8 +281,6 @@ static int wacom_parse_hid(struct hid_device *hdev,
}
} else if (pen) {
/* penabled only accepts exact bytes of data */
- if (features->type >= TABLETPC)
- features->pktlen = WACOM_PKGLEN_GRAPHIRE;
features->device_type = BTN_TOOL_PEN;
features->x_max =
get_unaligned_le16(&report[i + 3]);
@@ -1227,12 +1201,34 @@ static void wacom_calculate_res(struct wacom_features *features)
features->unitExpo);
}

+static int wacom_hid_report_len(struct hid_report *report)
+{
+ /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */
+ return ((report->size - 1) >> 3) + 1 + (report->id > 0);
+}
+
+static size_t wacom_compute_pktlen(struct hid_device *hdev)
+{
+ struct hid_report_enum *report_enum;
+ struct hid_report *report;
+ size_t size = 0;
+
+ report_enum = hdev->report_enum + HID_INPUT_REPORT;
+
+ list_for_each_entry(report, &report_enum->report_list, list) {
+ size_t report_size = wacom_hid_report_len(report);
+ if (report_size > size)
+ size = report_size;
+ }
+
+ return size;
+}
+
static int wacom_probe(struct hid_device *hdev,
const struct hid_device_id *id)
{
struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
struct usb_device *dev = interface_to_usbdev(intf);
- struct usb_endpoint_descriptor *endpoint;
struct wacom *wacom;
struct wacom_wac *wacom_wac;
struct wacom_features *features;
@@ -1258,6 +1254,7 @@ static int wacom_probe(struct hid_device *hdev,
wacom_wac = &wacom->wacom_wac;
wacom_wac->features = *((struct wacom_features *)id->driver_data);
features = &wacom_wac->features;
+ features->pktlen = wacom_compute_pktlen(hdev);
if (features->pktlen > WACOM_PKGLEN_MAX) {
error = -EINVAL;
goto fail1;
@@ -1275,8 +1272,6 @@ static int wacom_probe(struct hid_device *hdev,
usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
strlcat(wacom->phys, "/input0", sizeof(wacom->phys));

- endpoint = &intf->cur_altsetting->endpoint[0].desc;
-
/* set the default size in case we do not get them from hid */
wacom_set_default_phy(features);

@@ -1287,13 +1282,12 @@ static int wacom_probe(struct hid_device *hdev,

/*
* Intuos5 has no useful data about its touch interface in its
- * HID descriptor. If this is the touch interface (wMaxPacketSize
+ * HID descriptor. If this is the touch interface (PacketSize
* of WACOM_PKGLEN_BBTOUCH3), override the table values.
*/
if (features->type >= INTUOS5S && features->type <= INTUOSHT) {
- if (endpoint->wMaxPacketSize == WACOM_PKGLEN_BBTOUCH3) {
+ if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
features->device_type = BTN_TOOL_FINGER;
- features->pktlen = WACOM_PKGLEN_BBTOUCH3;

features->x_max = 4096;
features->y_max = 4096;
--
2.0.0

2014-06-30 21:31:10

by Benjamin Tissoires

[permalink] [raw]
Subject: [PATCH 04/15] Input - wacom: use HID core to actually fetch the report descriptor

HID core already retrieves the report descritor. There is no need
to ask ourself for one.

Signed-off-by: Benjamin Tissoires <[email protected]>
---
drivers/input/tablet/wacom_sys.c | 70 ++++++----------------------------------
1 file changed, 10 insertions(+), 60 deletions(-)

diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index eb39314..cd3d936 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -15,9 +15,6 @@
#include "wacom.h"
#include <linux/hid.h>

-/* defines to get HID report descriptor */
-#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
-#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
#define HID_HDESC_USAGE_UNDEFINED 0x00
#define HID_HDESC_USAGE_PAGE 0x05
#define HID_HDESC_USAGE 0x09
@@ -25,15 +22,6 @@
#define HID_HDESC_COLLECTION_LOGICAL 0x02
#define HID_HDESC_COLLECTION_END 0xc0

-struct wac_hid_descriptor {
- struct usb_descriptor_header header;
- __le16 bcdHID;
- u8 bCountryCode;
- u8 bNumDescriptors;
- u8 bDescriptorType;
- __le16 wDescriptorLength;
-} __attribute__ ((packed));
-
#define WAC_MSG_RETRIES 5

#define WAC_CMD_LED_CONTROL 0x20
@@ -230,39 +218,14 @@ static void wacom_retrieve_report_data(struct hid_device *hdev,
* this after returning from this function.
*/
static int wacom_parse_hid(struct hid_device *hdev,
- struct wac_hid_descriptor *hid_desc,
struct wacom_features *features)
{
- struct wacom *wacom = hid_get_drvdata(hdev);
- struct usb_interface *intf = wacom->intf;
- struct usb_device *dev = interface_to_usbdev(intf);
- char limit = 0;
/* result has to be defined as int for some devices */
int result = 0, touch_max = 0;
int i = 0, page = 0, finger = 0, pen = 0;
- unsigned char *report;
+ unsigned char *report = hdev->rdesc;

- report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL);
- if (!report)
- return -ENOMEM;
-
- /* retrive report descriptors */
- do {
- result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
- USB_REQ_GET_DESCRIPTOR,
- USB_RECIP_INTERFACE | USB_DIR_IN,
- HID_DEVICET_REPORT << 8,
- intf->altsetting[0].desc.bInterfaceNumber, /* interface */
- report,
- hid_desc->wDescriptorLength,
- 5000); /* 5 secs */
- } while (result < 0 && limit++ < WAC_MSG_RETRIES);
-
- /* No need to parse the Descriptor. It isn't an error though */
- if (result < 0)
- goto out;
-
- for (i = 0; i < hid_desc->wDescriptorLength; i++) {
+ for (i = 0; i < hdev->rsize; i++) {

switch (report[i]) {
case HID_HDESC_USAGE_PAGE:
@@ -452,11 +415,9 @@ static int wacom_parse_hid(struct hid_device *hdev,
}
}

- out:
if (!features->touch_max && touch_max)
features->touch_max = touch_max;
result = 0;
- kfree(report);
return result;
}

@@ -519,8 +480,6 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
int error = 0;
struct wacom *wacom = hid_get_drvdata(hdev);
struct usb_interface *intf = wacom->intf;
- struct usb_host_interface *interface = intf->cur_altsetting;
- struct wac_hid_descriptor *hid_desc;

/* default features */
features->device_type = BTN_TOOL_PEN;
@@ -549,17 +508,7 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
goto out;
}

- error = usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc);
- if (error) {
- error = usb_get_extra_descriptor(&interface->endpoint[0],
- HID_DEVICET_REPORT, &hid_desc);
- if (error) {
- hid_err(hdev,
- "can not retrieve extra class descriptor\n");
- goto out;
- }
- }
- error = wacom_parse_hid(hdev, hid_desc, features);
+ error = wacom_parse_hid(hdev, features);

out:
return error;
@@ -1299,6 +1248,13 @@ static int wacom_probe(struct hid_device *hdev,
hid_set_drvdata(hdev, wacom);
wacom->hdev = hdev;

+ /* ask for the report descriptor to be loaded by HID */
+ error = hid_parse(hdev);
+ if (error) {
+ hid_err(hdev, "parse failed\n");
+ goto fail1;
+ }
+
wacom_wac = &wacom->wacom_wac;
wacom_wac->features = *((struct wacom_features *)id->driver_data);
features = &wacom_wac->features;
@@ -1392,12 +1348,6 @@ static int wacom_probe(struct hid_device *hdev,
wacom_query_tablet_data(hdev, features);

/* Regular HID work starts now */
- error = hid_parse(hdev);
- if (error) {
- hid_err(hdev, "parse failed\n");
- goto fail4;
- }
-
error = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
if (error) {
hid_err(hdev, "hw start failed\n");
--
2.0.0

2014-07-02 21:40:20

by Benjamin Tissoires

[permalink] [raw]
Subject: Re: [PATCH 15/15] Input - wacom: keep wacom_ids ordered

On Mon, Jun 30, 2014 at 5:26 PM, Benjamin Tissoires
<[email protected]> wrote:
> No Functional changes, just some reordering.
>
> Signed-off-by: Benjamin Tissoires <[email protected]>
> ---
> drivers/input/tablet/wacom_wac.c | 75 ++++++++++++++++++++--------------------
> 1 file changed, 37 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/input/tablet/wacom_wac.c b/drivers/input/tablet/wacom_wac.c
> index 15b0132..de033d5 100644
> --- a/drivers/input/tablet/wacom_wac.c
> +++ b/drivers/input/tablet/wacom_wac.c
> @@ -2418,6 +2418,7 @@ static const struct wacom_features wacom_features_0x0309 =
>
> const struct hid_device_id wacom_ids[] = {
> { USB_DEVICE_WACOM(0x00) },
> + { USB_DEVICE_WACOM(0x03) },
> { USB_DEVICE_WACOM(0x10) },
> { USB_DEVICE_WACOM(0x11) },
> { USB_DEVICE_WACOM(0x12) },
> @@ -2428,20 +2429,16 @@ const struct hid_device_id wacom_ids[] = {
> { USB_DEVICE_WACOM(0x17) },
> { USB_DEVICE_WACOM(0x18) },
> { USB_DEVICE_WACOM(0x19) },
> - { USB_DEVICE_WACOM(0x60) },
> - { USB_DEVICE_WACOM(0x61) },
> - { USB_DEVICE_WACOM(0x62) },
> - { USB_DEVICE_WACOM(0x63) },
> - { USB_DEVICE_WACOM(0x64) },
> - { USB_DEVICE_WACOM(0x65) },
> - { USB_DEVICE_WACOM(0x69) },
> - { USB_DEVICE_WACOM(0x6A) },
> - { USB_DEVICE_WACOM(0x6B) },
> { USB_DEVICE_WACOM(0x20) },
> { USB_DEVICE_WACOM(0x21) },
> { USB_DEVICE_WACOM(0x22) },
> { USB_DEVICE_WACOM(0x23) },
> { USB_DEVICE_WACOM(0x24) },
> + { USB_DEVICE_WACOM(0x26) },
> + { USB_DEVICE_WACOM(0x27) },
> + { USB_DEVICE_WACOM(0x28) },
> + { USB_DEVICE_WACOM(0x29) },
> + { USB_DEVICE_WACOM(0x2A) },
> { USB_DEVICE_WACOM(0x30) },
> { USB_DEVICE_WACOM(0x31) },
> { USB_DEVICE_WACOM(0x32) },
> @@ -2451,20 +2448,33 @@ const struct hid_device_id wacom_ids[] = {
> { USB_DEVICE_WACOM(0x37) },
> { USB_DEVICE_WACOM(0x38) },
> { USB_DEVICE_WACOM(0x39) },
> - { USB_DEVICE_WACOM(0xC4) },
> - { USB_DEVICE_WACOM(0xC0) },
> - { USB_DEVICE_WACOM(0xC2) },
> - { USB_DEVICE_WACOM(0x03) },
> + { USB_DEVICE_WACOM(0x3F) },
> { USB_DEVICE_WACOM(0x41) },
> { USB_DEVICE_WACOM(0x42) },
> { USB_DEVICE_WACOM(0x43) },
> { USB_DEVICE_WACOM(0x44) },
> { USB_DEVICE_WACOM(0x45) },
> + { USB_DEVICE_WACOM(0x47) },
> { USB_DEVICE_WACOM(0x57) },
> { USB_DEVICE_WACOM(0x59) },
> - { USB_DEVICE_WACOM(0x5D) },
> { USB_DEVICE_WACOM(0x5B) },
> + { USB_DEVICE_WACOM(0x5D) },
> { USB_DEVICE_WACOM(0x5E) },
> + { USB_DEVICE_WACOM(0x60) },
> + { USB_DEVICE_WACOM(0x61) },
> + { USB_DEVICE_WACOM(0x62) },
> + { USB_DEVICE_WACOM(0x63) },
> + { USB_DEVICE_WACOM(0x64) },
> + { USB_DEVICE_WACOM(0x65) },
> + { USB_DEVICE_WACOM(0x69) },
> + { USB_DEVICE_WACOM(0x6A) },
> + { USB_DEVICE_WACOM(0x6B) },
> + { USB_DEVICE_WACOM(0x84) },
> + { USB_DEVICE_WACOM(0x90) },
> + { USB_DEVICE_WACOM(0x93) },
> + { USB_DEVICE_WACOM(0x97) },
> + { USB_DEVICE_WACOM(0x9A) },
> + { USB_DEVICE_WACOM(0x9F) },
> { USB_DEVICE_WACOM(0xB0) },
> { USB_DEVICE_WACOM(0xB1) },
> { USB_DEVICE_WACOM(0xB2) },
> @@ -2477,17 +2487,14 @@ const struct hid_device_id wacom_ids[] = {
> { USB_DEVICE_WACOM(0xBA) },
> { USB_DEVICE_WACOM(0xBB) },
> { USB_DEVICE_WACOM(0xBC) },
> - { USB_DEVICE_WACOM(0x26) },
> - { USB_DEVICE_WACOM(0x27) },
> - { USB_DEVICE_WACOM(0x28) },
> - { USB_DEVICE_WACOM(0x29) },
> - { USB_DEVICE_WACOM(0x2A) },
> - { USB_DEVICE_WACOM(0x3F) },
> + { USB_DEVICE_WACOM(0xC0) },
> + { USB_DEVICE_WACOM(0xC2) },
> + { USB_DEVICE_WACOM(0xC4) },
> { USB_DEVICE_WACOM(0xC5) },
> { USB_DEVICE_WACOM(0xC6) },
> { USB_DEVICE_WACOM(0xC7) },
> + { USB_DEVICE_WACOM(0xCC) },
> { USB_DEVICE_WACOM(0xCE) },
> - { USB_DEVICE_WACOM(0x84) },
> { USB_DEVICE_WACOM(0xD0) },
> { USB_DEVICE_WACOM(0xD1) },
> { USB_DEVICE_WACOM(0xD2) },
> @@ -2502,13 +2509,6 @@ const struct hid_device_id wacom_ids[] = {
> { USB_DEVICE_WACOM(0xDD) },
> { USB_DEVICE_WACOM(0xDE) },
> { USB_DEVICE_WACOM(0xDF) },
> - { USB_DEVICE_WACOM(0xF0) },
> - { USB_DEVICE_WACOM(0xCC) },
> - { USB_DEVICE_WACOM(0x90) },
> - { USB_DEVICE_WACOM(0x93) },
> - { USB_DEVICE_WACOM(0x97) },
> - { USB_DEVICE_WACOM(0x9A) },
> - { USB_DEVICE_WACOM(0x9F) },
> { USB_DEVICE_WACOM(0xE2) },
> { USB_DEVICE_WACOM(0xE3) },
> { USB_DEVICE_WACOM(0xE5) },
> @@ -2516,6 +2516,12 @@ const struct hid_device_id wacom_ids[] = {
> { USB_DEVICE_WACOM(0xEC) },
> { USB_DEVICE_WACOM(0xED) },
> { USB_DEVICE_WACOM(0xEF) },
> + { USB_DEVICE_WACOM(0xF0) },
> + { USB_DEVICE_WACOM(0xF4) },
> + { USB_DEVICE_WACOM(0xF6) },
> + { USB_DEVICE_WACOM(0xF8) },
> + { USB_DEVICE_WACOM(0xFA) },
> + { USB_DEVICE_WACOM(0xFB) },
> { USB_DEVICE_WACOM(0x100) },
> { USB_DEVICE_WACOM(0x101) },
> { USB_DEVICE_WACOM(0x10D) },
> @@ -2526,8 +2532,10 @@ const struct hid_device_id wacom_ids[] = {
> { USB_DEVICE_WACOM(0x301) },
> { USB_DEVICE_WACOM(0x302) },
> { USB_DEVICE_WACOM(0x303) },
> - { USB_DEVICE_WACOM(0x30E) },
> { USB_DEVICE_WACOM(0x304) },
> + { USB_DEVICE_WACOM(0x307) },
> + { USB_DEVICE_WACOM(0x309) },

These two (307 and 309) should have kept their leading '0' during the
re-order. The compilation fails without it (I still don't understand
why I did not saw it).

I don't think it is worth sending a v2 right now, we have other
important things to discuss first :)

Cheers,
Benjamin

> + { USB_DEVICE_WACOM(0x30E) },
> { USB_DEVICE_WACOM(0x314) },
> { USB_DEVICE_WACOM(0x315) },
> { USB_DEVICE_WACOM(0x317) },
> @@ -2535,15 +2543,6 @@ const struct hid_device_id wacom_ids[] = {
> { USB_DEVICE_WACOM(0x4004) },
> { USB_DEVICE_WACOM(0x5000) },
> { USB_DEVICE_WACOM(0x5002) },
> - { USB_DEVICE_WACOM(0x47) },
> - { USB_DEVICE_WACOM(0xF4) },
> - { USB_DEVICE_WACOM(0xF8) },
> - { USB_DEVICE_WACOM(0xF6) },
> - { USB_DEVICE_WACOM(0xFA) },
> - { USB_DEVICE_WACOM(0xFB) },
> - { USB_DEVICE_WACOM(0x0307) },
> - { USB_DEVICE_WACOM(0x0309) },
> - { USB_DEVICE_LENOVO(0x6004) },
> { }
> };
> MODULE_DEVICE_TABLE(hid, wacom_ids);
> --
> 2.0.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2014-07-02 23:33:25

by Jason Gerecke

[permalink] [raw]
Subject: Re: [PATCH 00/15] Input - Wacom: switch from an USB to a HID driver

On Mon, Jun 30, 2014 at 2:26 PM, Benjamin Tissoires
<[email protected]> wrote:
> Hi guys,
>
> this patch series is a cleanup for the Wacom USB driver.
>
> I started working on this topic when I saw patches floating around which
> implemented a report descriptor parser within the wacom.ko module.
> However, we already have a nice HID subsystem which is more generic than the
> HID implementation we can find in this USB driver.
> Further details of the benefits (code reduction, regression tests) are hopefully
> explained in the commit messages of the corresponding patches.
>
> Also, I am working on a way to handle the new Wacom tablets in a more generic
> way in the hid tree, so consider this patch series as a first step in this
> direction.
>
> This patch series transfers the wacom.ko driver from the input tree into the hid
> tree. I did not made the corresponding move of the files in the series hoping
> that we will find a way to achieve it if this step is validated.
>
> IMO, the smoothest path would be that Jiri takes care of the wacom driver
> in the input tree (and that we move into into the hid subfolder). This can be
> achieve if the current pending wacom patches are applied in the hid tree too.
>
> Another solution could be to keep the wacom changes in the input tree and put the
> hid changes in the hid tree by using separate commits. Once 3.17 is out, we can
> then change the module into the hid subfolder.
>
> I wanted to send this patch series right now so we can figure out how we will
> handle the transition.
>
> I am pretty confident the patch series does not break any existing device
> (except for the required user space changes which can be handled correctly if
> we tackle them right now). The USB commands are executed in the same way,
> and the protocol handling is also done in the same way.
>
> Anyway, the net difference in lines of code (-307) should be enough to be of
> interest.
>
> Note: This patch series requires the current pending wacom patches to be applied.
> I set up a tree with all the patch applied if anyone wants to give a try:
> https://github.com/bentiss/linux/commits/hid-wacom-legacy-3.16-rc3
>
> Cheers,
> Benjamin
>
> Benjamin Tissoires (15):
> Input - wacom: include and use linux/hid.h
> Input - wacom: switch from an USB driver to a HID driver
> Input - wacom: use hid communication instead of plain usb
> Input - wacom: use HID core to actually fetch the report descriptor
> Input - wacom: compute the HID report size to get the actual packet
> size
> Input - wacom: install LED/OLED sysfs files in the HID device instead
> of USB
> Input - wacom: register the input devices on top of the HID one
> Input - wacom: remove usb dependency for siblings devices
> Input - wacom: register power device at the HID level
> Input - wacom: use hid_info instead of plain dev_info
> HID: uhid: add and set HID_TYPE_UHID for uhid devices
> Input - wacom: use in-kernel HID parser
> Input - wacom: use hidinput_calc_abs_res instead of duplicating its
> code
> Input - wacom: remove field pktlen declaration in the list of devices
> Input - wacom: keep wacom_ids ordered
>
> drivers/hid/hid-core.c | 15 +-
> drivers/hid/hid-wacom.c | 2 +-
> drivers/hid/uhid.c | 2 +
> drivers/input/tablet/wacom.h | 7 +-
> drivers/input/tablet/wacom_sys.c | 908 +++++++++++++--------------------------
> drivers/input/tablet/wacom_wac.c | 647 ++++++++++++++--------------
> drivers/input/tablet/wacom_wac.h | 10 +-
> include/linux/hid.h | 4 +-
> 8 files changed, 644 insertions(+), 951 deletions(-)
>
> --
> 2.0.0
>

*cracks knuckles*

Well, guess I better get to work poking and prodding at these and the
pad patches. A very quick review doesn't raise any significant flags,
though I do have a question or two that I might have for you in the
next few days (need to read through the code more carefully to be sure
I understand it correctly). My 24HDT is having some trouble
initializing with the patches applied, but I'll need some time to
track down the cause. Not sure how much I'll get done this week
(holiday weekend) but next week I should have some feedback.

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....

2014-07-03 09:37:38

by Przemo Firszt

[permalink] [raw]
Subject: Re: [Linuxwacom-devel] [PATCH 06/15] Input - wacom: install LED/OLED sysfs files in the HID device instead of USB


Quoting Benjamin Tissoires <[email protected]>:

> Removes one more dependency over USB, but requires some changes in
> the user space to find the sysfs files correctly.
>
> This patch breaks the user space. However, the number of program
> accessing the LEDs is quite limited and we can easily patch them
> to handle the new HID behavior.
[..]
Hi Bejnamin,
If you get the green light to break the user space we might as well
think about getting it in line with led/oled over bluetooth (intuos4
wireless) or the other way around.

The biggest user of led/oled functionality is gnome and there are also
a few small projects that would stop working after that change. I can
fix i4oled project easily, i4oled-gui is based on gnome handling oleds.

Patching those 2 should be enough to fix gnome:
https://git.gnome.org/browse/gnome-settings-daemon/tree/plugins/wacom/gsd-wacom-led-helper.c
https://git.gnome.org/browse/gnome-settings-daemon/tree/plugins/wacom/gsd-wacom-oled-helper.c

Regards,
Przemo Firszt

2014-07-03 13:46:28

by Benjamin Tissoires

[permalink] [raw]
Subject: Re: [Linuxwacom-devel] [PATCH 06/15] Input - wacom: install LED/OLED sysfs files in the HID device instead of USB

Hi Przemo,

On Jul 03 2014 or thereabouts, Przemo Firszt wrote:
>
> Quoting Benjamin Tissoires <[email protected]>:
>
> >Removes one more dependency over USB, but requires some changes in
> >the user space to find the sysfs files correctly.
> >
> >This patch breaks the user space. However, the number of program
> >accessing the LEDs is quite limited and we can easily patch them
> >to handle the new HID behavior.
> [..]
> Hi Bejnamin,
> If you get the green light to break the user space we might as well think
> about getting it in line with led/oled over bluetooth (intuos4 wireless) or
> the other way around.

I think it would be easier to fix the bluetooth (current hid) driver. I
think you already implemented the bluetooth handling in gnome 3.12 and
3.13, but having an uniform way of accessing the LEDs/OLEDs would be
nice.

>
> The biggest user of led/oled functionality is gnome and there are also a few
> small projects that would stop working after that change. I can fix i4oled
> project easily, i4oled-gui is based on gnome handling oleds.

I tried i4oled-gui last week or so, and patching g-s-d was enough. That
was a good idea to rely on gnome internals for your tool :)

>
> Patching those 2 should be enough to fix gnome:
> https://git.gnome.org/browse/gnome-settings-daemon/tree/plugins/wacom/gsd-wacom-led-helper.c
> https://git.gnome.org/browse/gnome-settings-daemon/tree/plugins/wacom/gsd-wacom-oled-helper.c

Yes, those two are sufficient enough. I had to make the patches
(http://paste.fedoraproject.org/115318/14043949/) so I could test that nothing
was broken. I'll submit those as soon as the fate of this conversion is
decided.

The current libwacom code also need a fix to handle the hid devices
(bluetooth and this series), and I have to send it for a while now :(

Cheers,
Benjamin

2014-07-10 23:07:29

by Przemo Firszt

[permalink] [raw]
Subject: Re: [Linuxwacom-devel] [PATCH 00/15] Input - Wacom: switch from an USB to a HID driver

Hi Benjamin,
I'm having some problems to cleanly apply your patches - can you double
check that they are OK?
--
Regards,
Przemo

2014-07-11 00:10:35

by Jason Gerecke

[permalink] [raw]
Subject: Re: [PATCH 08/15] Input - wacom: remove usb dependency for siblings devices

On Mon, Jun 30, 2014 at 2:26 PM, Benjamin Tissoires
<[email protected]> wrote:
> Wacom tablets can share different physical sensors on one physical device.
> These are called siblings in the code. The current way of implementation
> relies on the USB topology to be able to share data amongs those sensors.
>
> We can replace the code to match a HID subsystem, without involving the USB
> topology:
> - the first probed sensor does not find any siblings in the list
> wacom_udev_list, so it creates its own wacom_hdev_data with its own
> struct hid_device
> - the other sensor checks the current list of siblings in wacom_hdev_data,
> and if there is a match, it associates itself to the matched device.
>
> To be sure that we are not associating different sensors from different
> physical devices, we also check for the phys path of the hid device which
> contains the USB topology.
>
> Signed-off-by: Benjamin Tissoires <[email protected]>
> ---
> drivers/input/tablet/wacom_sys.c | 75 +++++++++++++++++++---------------------
> 1 file changed, 35 insertions(+), 40 deletions(-)
>
> diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
> index 0d0397d..6fe7a6c 100644
> --- a/drivers/input/tablet/wacom_sys.c
> +++ b/drivers/input/tablet/wacom_sys.c
> @@ -488,46 +488,45 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
> return error;
> }
>
> -struct wacom_usbdev_data {
> +struct wacom_hdev_data {
> struct list_head list;
> struct kref kref;
> - struct usb_device *dev;
> + struct hid_device *dev;
> struct wacom_shared shared;
> };
>
> static LIST_HEAD(wacom_udev_list);
> static DEFINE_MUTEX(wacom_udev_list_lock);
>
> -static struct usb_device *wacom_get_sibling(struct usb_device *dev, int vendor, int product)
> +static bool wacom_are_sibling(struct hid_device *hdev,
> + struct hid_device *sibling)
> {
> - int port1;
> - struct usb_device *sibling;
> -
> - if (vendor == 0 && product == 0)
> - return dev;
> -
> - if (dev->parent == NULL)
> - return NULL;
> -
> - usb_hub_for_each_child(dev->parent, port1, sibling) {
> - struct usb_device_descriptor *d;
> - if (sibling == NULL)
> - continue;
> + struct wacom *wacom = hid_get_drvdata(hdev);
> + struct wacom_features *features = &wacom->wacom_wac.features;
> + int vid = features->oVid;
> + int pid = features->oPid;
>
> - d = &sibling->descriptor;
> - if (d->idVendor == vendor && d->idProduct == product)
> - return sibling;
> + if (vid == 0 && pid == 0) {
> + vid = hdev->vendor;
> + pid = hdev->product;
> }
>
> - return NULL;
> + if (vid != sibling->vendor || pid != sibling->product)
> + return false;
> +
> + /*
> + * Compare the physical path.
> + * Dump the last two chars which should contain the input number.
> + */
> + return !strncmp(hdev->phys, sibling->phys, strlen(hdev->phys) - 2);

Good idea, but this implementation doesn't work. "Siblings" (such as
you'd find on a 24HDT) are separate USB devices but share the same USB
hub. Trimming off just the input number isn't sufficient since the USB
path preceding it is going to be different for the two devices. For
example, I the touch and pen interfaces on my 24HDT show up as
"usb-0000:00:1d.0-1.4.3/input0" and "usb-0000:00:1d.0-1.4.2/input1".

Something like the following could work though:

int n1 = strrchr(hdev->phys, '.') - hdev->phys;
int n2 = strrchr(sibling->phys, '.') - sibling->phys;
if (n1 != n2 || n1 <= 0 || n2 <= 0)
return false;
else
return !strncmp(hdev->phys, sibling->phys, n1);

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....

> }
>
> -static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
> +static struct wacom_hdev_data *wacom_get_hdev_data(struct hid_device *hdev)
> {
> - struct wacom_usbdev_data *data;
> + struct wacom_hdev_data *data;
>
> list_for_each_entry(data, &wacom_udev_list, list) {
> - if (data->dev == dev) {
> + if (wacom_are_sibling(hdev, data->dev)) {
> kref_get(&data->kref);
> return data;
> }
> @@ -536,28 +535,29 @@ static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
> return NULL;
> }
>
> -static int wacom_add_shared_data(struct wacom_wac *wacom,
> - struct usb_device *dev)
> +static int wacom_add_shared_data(struct hid_device *hdev)
> {
> - struct wacom_usbdev_data *data;
> + struct wacom *wacom = hid_get_drvdata(hdev);
> + struct wacom_wac *wacom_wac = &wacom->wacom_wac;
> + struct wacom_hdev_data *data;
> int retval = 0;
>
> mutex_lock(&wacom_udev_list_lock);
>
> - data = wacom_get_usbdev_data(dev);
> + data = wacom_get_hdev_data(hdev);
> if (!data) {
> - data = kzalloc(sizeof(struct wacom_usbdev_data), GFP_KERNEL);
> + data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL);
> if (!data) {
> retval = -ENOMEM;
> goto out;
> }
>
> kref_init(&data->kref);
> - data->dev = dev;
> + data->dev = hdev;
> list_add_tail(&data->list, &wacom_udev_list);
> }
>
> - wacom->shared = &data->shared;
> + wacom_wac->shared = &data->shared;
>
> out:
> mutex_unlock(&wacom_udev_list_lock);
> @@ -566,8 +566,8 @@ out:
>
> static void wacom_release_shared_data(struct kref *kref)
> {
> - struct wacom_usbdev_data *data =
> - container_of(kref, struct wacom_usbdev_data, kref);
> + struct wacom_hdev_data *data =
> + container_of(kref, struct wacom_hdev_data, kref);
>
> mutex_lock(&wacom_udev_list_lock);
> list_del(&data->list);
> @@ -578,10 +578,10 @@ static void wacom_release_shared_data(struct kref *kref)
>
> static void wacom_remove_shared_data(struct wacom_wac *wacom)
> {
> - struct wacom_usbdev_data *data;
> + struct wacom_hdev_data *data;
>
> if (wacom->shared) {
> - data = container_of(wacom->shared, struct wacom_usbdev_data, shared);
> + data = container_of(wacom->shared, struct wacom_hdev_data, shared);
> kref_put(&data->kref, wacom_release_shared_data);
> wacom->shared = NULL;
> }
> @@ -1311,8 +1311,6 @@ static int wacom_probe(struct hid_device *hdev,
> "%s Pad", features->name);
>
> if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
> - struct usb_device *other_dev;
> -
> /* Append the device type to the name */
> if (features->device_type != BTN_TOOL_FINGER)
> strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX);
> @@ -1321,10 +1319,7 @@ static int wacom_probe(struct hid_device *hdev,
> else
> strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX);
>
> - other_dev = wacom_get_sibling(dev, features->oVid, features->oPid);
> - if (other_dev == NULL || wacom_get_usbdev_data(other_dev) == NULL)
> - other_dev = dev;
> - error = wacom_add_shared_data(wacom_wac, other_dev);
> + error = wacom_add_shared_data(hdev);
> if (error)
> goto fail1;
> }
> --
> 2.0.0
>

2014-07-11 01:10:04

by Jason Gerecke

[permalink] [raw]
Subject: Re: [PATCH 05/15] Input - wacom: compute the HID report size to get the actual packet size

On Mon, Jun 30, 2014 at 2:26 PM, Benjamin Tissoires
<[email protected]> wrote:
> This removes an USB dependency and is more accurate: the computed pktlen
> is the actual maximum size of the reports forwarded by the device.
>
> Given that the pktlen is correctly computed/validated, we can store it now
> in the features struct instead of having a special handling in the rest of
> the code.
>
> Likewise, this information is not mandatory anymore in the description
> of devices in wacom_wac.c. They will be removed in a separate patch.
>
> Signed-off-by: Benjamin Tissoires <[email protected]>

I'm concerned this new function could be fooled if we release a tablet
that has one report which is longer than the desired report, but none
of the hardware I tested was like this and it would be fairly easy to
address even if it did happen. Thought I should mention it though.

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....


> ---
> drivers/input/tablet/wacom_sys.c | 58 ++++++++++++++++++----------------------
> 1 file changed, 26 insertions(+), 32 deletions(-)
>
> diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
> index cd3d936..3f1cee6 100644
> --- a/drivers/input/tablet/wacom_sys.c
> +++ b/drivers/input/tablet/wacom_sys.c
> @@ -149,7 +149,6 @@ static int wacom_parse_logical_collection(unsigned char *report,
> if (features->type == BAMBOO_PT) {
>
> /* Logical collection is only used by 3rd gen Bamboo Touch */
> - features->pktlen = WACOM_PKGLEN_BBTOUCH3;
> features->device_type = BTN_TOOL_FINGER;
>
> features->x_max = features->y_max =
> @@ -240,29 +239,6 @@ static int wacom_parse_hid(struct hid_device *hdev,
> features->device_type = BTN_TOOL_FINGER;
> /* touch device at least supports one touch point */
> touch_max = 1;
> - switch (features->type) {
> - case TABLETPC2FG:
> - features->pktlen = WACOM_PKGLEN_TPC2FG;
> - break;
> -
> - case MTSCREEN:
> - case WACOM_24HDT:
> - features->pktlen = WACOM_PKGLEN_MTOUCH;
> - break;
> -
> - case MTTPC:
> - case MTTPC_B:
> - features->pktlen = WACOM_PKGLEN_MTTPC;
> - break;
> -
> - case BAMBOO_PT:
> - features->pktlen = WACOM_PKGLEN_BBTOUCH;
> - break;
> -
> - default:
> - features->pktlen = WACOM_PKGLEN_GRAPHIRE;
> - break;
> - }
>
> switch (features->type) {
> case BAMBOO_PT:
> @@ -305,8 +281,6 @@ static int wacom_parse_hid(struct hid_device *hdev,
> }
> } else if (pen) {
> /* penabled only accepts exact bytes of data */
> - if (features->type >= TABLETPC)
> - features->pktlen = WACOM_PKGLEN_GRAPHIRE;
> features->device_type = BTN_TOOL_PEN;
> features->x_max =
> get_unaligned_le16(&report[i + 3]);
> @@ -1227,12 +1201,34 @@ static void wacom_calculate_res(struct wacom_features *features)
> features->unitExpo);
> }
>
> +static int wacom_hid_report_len(struct hid_report *report)
> +{
> + /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */
> + return ((report->size - 1) >> 3) + 1 + (report->id > 0);
> +}
> +
> +static size_t wacom_compute_pktlen(struct hid_device *hdev)
> +{
> + struct hid_report_enum *report_enum;
> + struct hid_report *report;
> + size_t size = 0;
> +
> + report_enum = hdev->report_enum + HID_INPUT_REPORT;
> +
> + list_for_each_entry(report, &report_enum->report_list, list) {
> + size_t report_size = wacom_hid_report_len(report);
> + if (report_size > size)
> + size = report_size;
> + }
> +
> + return size;
> +}
> +
> static int wacom_probe(struct hid_device *hdev,
> const struct hid_device_id *id)
> {
> struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
> struct usb_device *dev = interface_to_usbdev(intf);
> - struct usb_endpoint_descriptor *endpoint;
> struct wacom *wacom;
> struct wacom_wac *wacom_wac;
> struct wacom_features *features;
> @@ -1258,6 +1254,7 @@ static int wacom_probe(struct hid_device *hdev,
> wacom_wac = &wacom->wacom_wac;
> wacom_wac->features = *((struct wacom_features *)id->driver_data);
> features = &wacom_wac->features;
> + features->pktlen = wacom_compute_pktlen(hdev);
> if (features->pktlen > WACOM_PKGLEN_MAX) {
> error = -EINVAL;
> goto fail1;
> @@ -1275,8 +1272,6 @@ static int wacom_probe(struct hid_device *hdev,
> usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
> strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
>
> - endpoint = &intf->cur_altsetting->endpoint[0].desc;
> -
> /* set the default size in case we do not get them from hid */
> wacom_set_default_phy(features);
>
> @@ -1287,13 +1282,12 @@ static int wacom_probe(struct hid_device *hdev,
>
> /*
> * Intuos5 has no useful data about its touch interface in its
> - * HID descriptor. If this is the touch interface (wMaxPacketSize
> + * HID descriptor. If this is the touch interface (PacketSize
> * of WACOM_PKGLEN_BBTOUCH3), override the table values.
> */
> if (features->type >= INTUOS5S && features->type <= INTUOSHT) {
> - if (endpoint->wMaxPacketSize == WACOM_PKGLEN_BBTOUCH3) {
> + if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
> features->device_type = BTN_TOOL_FINGER;
> - features->pktlen = WACOM_PKGLEN_BBTOUCH3;
>
> features->x_max = 4096;
> features->y_max = 4096;
> --
> 2.0.0
>

2014-07-11 01:17:27

by Jason Gerecke

[permalink] [raw]
Subject: Re: [PATCH 00/15] Input - Wacom: switch from an USB to a HID driver

On Wed, Jul 2, 2014 at 4:33 PM, Jason Gerecke <[email protected]> wrote:
> On Mon, Jun 30, 2014 at 2:26 PM, Benjamin Tissoires
> <[email protected]> wrote:
>> Hi guys,
>>
>> this patch series is a cleanup for the Wacom USB driver.
>>
>> I started working on this topic when I saw patches floating around which
>> implemented a report descriptor parser within the wacom.ko module.
>> However, we already have a nice HID subsystem which is more generic than the
>> HID implementation we can find in this USB driver.
>> Further details of the benefits (code reduction, regression tests) are hopefully
>> explained in the commit messages of the corresponding patches.
>>
>> Also, I am working on a way to handle the new Wacom tablets in a more generic
>> way in the hid tree, so consider this patch series as a first step in this
>> direction.
>>
>> This patch series transfers the wacom.ko driver from the input tree into the hid
>> tree. I did not made the corresponding move of the files in the series hoping
>> that we will find a way to achieve it if this step is validated.
>>
>> IMO, the smoothest path would be that Jiri takes care of the wacom driver
>> in the input tree (and that we move into into the hid subfolder). This can be
>> achieve if the current pending wacom patches are applied in the hid tree too.
>>
>> Another solution could be to keep the wacom changes in the input tree and put the
>> hid changes in the hid tree by using separate commits. Once 3.17 is out, we can
>> then change the module into the hid subfolder.
>>
>> I wanted to send this patch series right now so we can figure out how we will
>> handle the transition.
>>
>> I am pretty confident the patch series does not break any existing device
>> (except for the required user space changes which can be handled correctly if
>> we tackle them right now). The USB commands are executed in the same way,
>> and the protocol handling is also done in the same way.
>>
>> Anyway, the net difference in lines of code (-307) should be enough to be of
>> interest.
>>
>> Note: This patch series requires the current pending wacom patches to be applied.
>> I set up a tree with all the patch applied if anyone wants to give a try:
>> https://github.com/bentiss/linux/commits/hid-wacom-legacy-3.16-rc3
>>
>> Cheers,
>> Benjamin
>>
>> Benjamin Tissoires (15):
>> Input - wacom: include and use linux/hid.h
>> Input - wacom: switch from an USB driver to a HID driver
>> Input - wacom: use hid communication instead of plain usb
>> Input - wacom: use HID core to actually fetch the report descriptor
>> Input - wacom: compute the HID report size to get the actual packet
>> size
>> Input - wacom: install LED/OLED sysfs files in the HID device instead
>> of USB
>> Input - wacom: register the input devices on top of the HID one
>> Input - wacom: remove usb dependency for siblings devices
>> Input - wacom: register power device at the HID level
>> Input - wacom: use hid_info instead of plain dev_info
>> HID: uhid: add and set HID_TYPE_UHID for uhid devices
>> Input - wacom: use in-kernel HID parser
>> Input - wacom: use hidinput_calc_abs_res instead of duplicating its
>> code
>> Input - wacom: remove field pktlen declaration in the list of devices
>> Input - wacom: keep wacom_ids ordered
>>
>> drivers/hid/hid-core.c | 15 +-
>> drivers/hid/hid-wacom.c | 2 +-
>> drivers/hid/uhid.c | 2 +
>> drivers/input/tablet/wacom.h | 7 +-
>> drivers/input/tablet/wacom_sys.c | 908 +++++++++++++--------------------------
>> drivers/input/tablet/wacom_wac.c | 647 ++++++++++++++--------------
>> drivers/input/tablet/wacom_wac.h | 10 +-
>> include/linux/hid.h | 4 +-
>> 8 files changed, 644 insertions(+), 951 deletions(-)
>>
>> --
>> 2.0.0
>>
>
> *cracks knuckles*
>
> Well, guess I better get to work poking and prodding at these and the
> pad patches. A very quick review doesn't raise any significant flags,
> though I do have a question or two that I might have for you in the
> next few days (need to read through the code more carefully to be sure
> I understand it correctly). My 24HDT is having some trouble
> initializing with the patches applied, but I'll need some time to
> track down the cause. Not sure how much I'll get done this week
> (holiday weekend) but next week I should have some feedback.
>
> Jason
> ---
> Now instead of four in the eights place /
> you’ve got three, ‘Cause you added one /
> (That is to say, eight) to the two, /
> But you can’t take seven from three, /
> So you look at the sixty-fours....

I've had a chance to try out a dozen tablets with these modifications
and for the most part things seem to work fine. The 24HDT issue I
mentioned above was due to a conflict with some other patches I was
testing and can be ignored. Aside from the other known issues you've
already mentioned (and my inline comments), there's not much that I
can say (other than that I found some odd [but apparently unrelated]
issues with wacom_w8001 and isdv4-serial-inputattach...)

Reviewed-by: Jason Gerecke <[email protected]>
Tested-by: Jason Gerecke <[email protected]>

Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....

2014-07-11 13:15:43

by Benjamin Tissoires

[permalink] [raw]
Subject: Re: [PATCH 08/15] Input - wacom: remove usb dependency for siblings devices

On Thu, Jul 10, 2014 at 8:10 PM, Jason Gerecke <[email protected]> wrote:
> On Mon, Jun 30, 2014 at 2:26 PM, Benjamin Tissoires
> <[email protected]> wrote:
>> Wacom tablets can share different physical sensors on one physical device.
>> These are called siblings in the code. The current way of implementation
>> relies on the USB topology to be able to share data amongs those sensors.
>>
>> We can replace the code to match a HID subsystem, without involving the USB
>> topology:
>> - the first probed sensor does not find any siblings in the list
>> wacom_udev_list, so it creates its own wacom_hdev_data with its own
>> struct hid_device
>> - the other sensor checks the current list of siblings in wacom_hdev_data,
>> and if there is a match, it associates itself to the matched device.
>>
>> To be sure that we are not associating different sensors from different
>> physical devices, we also check for the phys path of the hid device which
>> contains the USB topology.
>>
>> Signed-off-by: Benjamin Tissoires <[email protected]>
>> ---
>> drivers/input/tablet/wacom_sys.c | 75 +++++++++++++++++++---------------------
>> 1 file changed, 35 insertions(+), 40 deletions(-)
>>
>> diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
>> index 0d0397d..6fe7a6c 100644
>> --- a/drivers/input/tablet/wacom_sys.c
>> +++ b/drivers/input/tablet/wacom_sys.c
>> @@ -488,46 +488,45 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
>> return error;
>> }
>>
>> -struct wacom_usbdev_data {
>> +struct wacom_hdev_data {
>> struct list_head list;
>> struct kref kref;
>> - struct usb_device *dev;
>> + struct hid_device *dev;
>> struct wacom_shared shared;
>> };
>>
>> static LIST_HEAD(wacom_udev_list);
>> static DEFINE_MUTEX(wacom_udev_list_lock);
>>
>> -static struct usb_device *wacom_get_sibling(struct usb_device *dev, int vendor, int product)
>> +static bool wacom_are_sibling(struct hid_device *hdev,
>> + struct hid_device *sibling)
>> {
>> - int port1;
>> - struct usb_device *sibling;
>> -
>> - if (vendor == 0 && product == 0)
>> - return dev;
>> -
>> - if (dev->parent == NULL)
>> - return NULL;
>> -
>> - usb_hub_for_each_child(dev->parent, port1, sibling) {
>> - struct usb_device_descriptor *d;
>> - if (sibling == NULL)
>> - continue;
>> + struct wacom *wacom = hid_get_drvdata(hdev);
>> + struct wacom_features *features = &wacom->wacom_wac.features;
>> + int vid = features->oVid;
>> + int pid = features->oPid;
>>
>> - d = &sibling->descriptor;
>> - if (d->idVendor == vendor && d->idProduct == product)
>> - return sibling;
>> + if (vid == 0 && pid == 0) {
>> + vid = hdev->vendor;
>> + pid = hdev->product;
>> }
>>
>> - return NULL;
>> + if (vid != sibling->vendor || pid != sibling->product)
>> + return false;
>> +
>> + /*
>> + * Compare the physical path.
>> + * Dump the last two chars which should contain the input number.
>> + */
>> + return !strncmp(hdev->phys, sibling->phys, strlen(hdev->phys) - 2);
>
> Good idea, but this implementation doesn't work. "Siblings" (such as
> you'd find on a 24HDT) are separate USB devices but share the same USB
> hub. Trimming off just the input number isn't sufficient since the USB
> path preceding it is going to be different for the two devices. For
> example, I the touch and pen interfaces on my 24HDT show up as
> "usb-0000:00:1d.0-1.4.3/input0" and "usb-0000:00:1d.0-1.4.2/input1".

You are right. I thought I managed to make the 22HDT working with my
patches, but maybe I overlooked it

>
> Something like the following could work though:
>
> int n1 = strrchr(hdev->phys, '.') - hdev->phys;
> int n2 = strrchr(sibling->phys, '.') - sibling->phys;
> if (n1 != n2 || n1 <= 0 || n2 <= 0)
> return false;
> else
> return !strncmp(hdev->phys, sibling->phys, n1);

Seems fair. I'll give a try and update the patches.

Thanks!

Cheers,
Benjamin

>
> Jason
> ---
> Now instead of four in the eights place /
> you’ve got three, ‘Cause you added one /
> (That is to say, eight) to the two, /
> But you can’t take seven from three, /
> So you look at the sixty-fours....
>
>> }
>>
>> -static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
>> +static struct wacom_hdev_data *wacom_get_hdev_data(struct hid_device *hdev)
>> {
>> - struct wacom_usbdev_data *data;
>> + struct wacom_hdev_data *data;
>>
>> list_for_each_entry(data, &wacom_udev_list, list) {
>> - if (data->dev == dev) {
>> + if (wacom_are_sibling(hdev, data->dev)) {
>> kref_get(&data->kref);
>> return data;
>> }
>> @@ -536,28 +535,29 @@ static struct wacom_usbdev_data *wacom_get_usbdev_data(struct usb_device *dev)
>> return NULL;
>> }
>>
>> -static int wacom_add_shared_data(struct wacom_wac *wacom,
>> - struct usb_device *dev)
>> +static int wacom_add_shared_data(struct hid_device *hdev)
>> {
>> - struct wacom_usbdev_data *data;
>> + struct wacom *wacom = hid_get_drvdata(hdev);
>> + struct wacom_wac *wacom_wac = &wacom->wacom_wac;
>> + struct wacom_hdev_data *data;
>> int retval = 0;
>>
>> mutex_lock(&wacom_udev_list_lock);
>>
>> - data = wacom_get_usbdev_data(dev);
>> + data = wacom_get_hdev_data(hdev);
>> if (!data) {
>> - data = kzalloc(sizeof(struct wacom_usbdev_data), GFP_KERNEL);
>> + data = kzalloc(sizeof(struct wacom_hdev_data), GFP_KERNEL);
>> if (!data) {
>> retval = -ENOMEM;
>> goto out;
>> }
>>
>> kref_init(&data->kref);
>> - data->dev = dev;
>> + data->dev = hdev;
>> list_add_tail(&data->list, &wacom_udev_list);
>> }
>>
>> - wacom->shared = &data->shared;
>> + wacom_wac->shared = &data->shared;
>>
>> out:
>> mutex_unlock(&wacom_udev_list_lock);
>> @@ -566,8 +566,8 @@ out:
>>
>> static void wacom_release_shared_data(struct kref *kref)
>> {
>> - struct wacom_usbdev_data *data =
>> - container_of(kref, struct wacom_usbdev_data, kref);
>> + struct wacom_hdev_data *data =
>> + container_of(kref, struct wacom_hdev_data, kref);
>>
>> mutex_lock(&wacom_udev_list_lock);
>> list_del(&data->list);
>> @@ -578,10 +578,10 @@ static void wacom_release_shared_data(struct kref *kref)
>>
>> static void wacom_remove_shared_data(struct wacom_wac *wacom)
>> {
>> - struct wacom_usbdev_data *data;
>> + struct wacom_hdev_data *data;
>>
>> if (wacom->shared) {
>> - data = container_of(wacom->shared, struct wacom_usbdev_data, shared);
>> + data = container_of(wacom->shared, struct wacom_hdev_data, shared);
>> kref_put(&data->kref, wacom_release_shared_data);
>> wacom->shared = NULL;
>> }
>> @@ -1311,8 +1311,6 @@ static int wacom_probe(struct hid_device *hdev,
>> "%s Pad", features->name);
>>
>> if (features->quirks & WACOM_QUIRK_MULTI_INPUT) {
>> - struct usb_device *other_dev;
>> -
>> /* Append the device type to the name */
>> if (features->device_type != BTN_TOOL_FINGER)
>> strlcat(wacom_wac->name, " Pen", WACOM_NAME_MAX);
>> @@ -1321,10 +1319,7 @@ static int wacom_probe(struct hid_device *hdev,
>> else
>> strlcat(wacom_wac->name, " Pad", WACOM_NAME_MAX);
>>
>> - other_dev = wacom_get_sibling(dev, features->oVid, features->oPid);
>> - if (other_dev == NULL || wacom_get_usbdev_data(other_dev) == NULL)
>> - other_dev = dev;
>> - error = wacom_add_shared_data(wacom_wac, other_dev);
>> + error = wacom_add_shared_data(hdev);
>> if (error)
>> goto fail1;
>> }
>> --
>> 2.0.0
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2014-07-11 13:21:00

by Benjamin Tissoires

[permalink] [raw]
Subject: Re: [PATCH 05/15] Input - wacom: compute the HID report size to get the actual packet size

On Thu, Jul 10, 2014 at 9:09 PM, Jason Gerecke <[email protected]> wrote:
> On Mon, Jun 30, 2014 at 2:26 PM, Benjamin Tissoires
> <[email protected]> wrote:
>> This removes an USB dependency and is more accurate: the computed pktlen
>> is the actual maximum size of the reports forwarded by the device.
>>
>> Given that the pktlen is correctly computed/validated, we can store it now
>> in the features struct instead of having a special handling in the rest of
>> the code.
>>
>> Likewise, this information is not mandatory anymore in the description
>> of devices in wacom_wac.c. They will be removed in a separate patch.
>>
>> Signed-off-by: Benjamin Tissoires <[email protected]>
>
> I'm concerned this new function could be fooled if we release a tablet
> that has one report which is longer than the desired report, but none
> of the hardware I tested was like this and it would be fairly easy to
> address even if it did happen. Thought I should mention it though.
>

You are right to mention it. But in the other hand, such a device
would violate the HID specification, and I am not sure the Windows
driver (which I don't know its internal) would be happy too.

Anyway, as you said, if there is such a device, we an use the report
descriptor fixup capability of HID to prevent this from happening.

Cheers,
Benjamin

> Jason
> ---
> Now instead of four in the eights place /
> you’ve got three, ‘Cause you added one /
> (That is to say, eight) to the two, /
> But you can’t take seven from three, /
> So you look at the sixty-fours....
>
>
>> ---
>> drivers/input/tablet/wacom_sys.c | 58 ++++++++++++++++++----------------------
>> 1 file changed, 26 insertions(+), 32 deletions(-)
>>
>> diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
>> index cd3d936..3f1cee6 100644
>> --- a/drivers/input/tablet/wacom_sys.c
>> +++ b/drivers/input/tablet/wacom_sys.c
>> @@ -149,7 +149,6 @@ static int wacom_parse_logical_collection(unsigned char *report,
>> if (features->type == BAMBOO_PT) {
>>
>> /* Logical collection is only used by 3rd gen Bamboo Touch */
>> - features->pktlen = WACOM_PKGLEN_BBTOUCH3;
>> features->device_type = BTN_TOOL_FINGER;
>>
>> features->x_max = features->y_max =
>> @@ -240,29 +239,6 @@ static int wacom_parse_hid(struct hid_device *hdev,
>> features->device_type = BTN_TOOL_FINGER;
>> /* touch device at least supports one touch point */
>> touch_max = 1;
>> - switch (features->type) {
>> - case TABLETPC2FG:
>> - features->pktlen = WACOM_PKGLEN_TPC2FG;
>> - break;
>> -
>> - case MTSCREEN:
>> - case WACOM_24HDT:
>> - features->pktlen = WACOM_PKGLEN_MTOUCH;
>> - break;
>> -
>> - case MTTPC:
>> - case MTTPC_B:
>> - features->pktlen = WACOM_PKGLEN_MTTPC;
>> - break;
>> -
>> - case BAMBOO_PT:
>> - features->pktlen = WACOM_PKGLEN_BBTOUCH;
>> - break;
>> -
>> - default:
>> - features->pktlen = WACOM_PKGLEN_GRAPHIRE;
>> - break;
>> - }
>>
>> switch (features->type) {
>> case BAMBOO_PT:
>> @@ -305,8 +281,6 @@ static int wacom_parse_hid(struct hid_device *hdev,
>> }
>> } else if (pen) {
>> /* penabled only accepts exact bytes of data */
>> - if (features->type >= TABLETPC)
>> - features->pktlen = WACOM_PKGLEN_GRAPHIRE;
>> features->device_type = BTN_TOOL_PEN;
>> features->x_max =
>> get_unaligned_le16(&report[i + 3]);
>> @@ -1227,12 +1201,34 @@ static void wacom_calculate_res(struct wacom_features *features)
>> features->unitExpo);
>> }
>>
>> +static int wacom_hid_report_len(struct hid_report *report)
>> +{
>> + /* equivalent to DIV_ROUND_UP(report->size, 8) + !!(report->id > 0) */
>> + return ((report->size - 1) >> 3) + 1 + (report->id > 0);
>> +}
>> +
>> +static size_t wacom_compute_pktlen(struct hid_device *hdev)
>> +{
>> + struct hid_report_enum *report_enum;
>> + struct hid_report *report;
>> + size_t size = 0;
>> +
>> + report_enum = hdev->report_enum + HID_INPUT_REPORT;
>> +
>> + list_for_each_entry(report, &report_enum->report_list, list) {
>> + size_t report_size = wacom_hid_report_len(report);
>> + if (report_size > size)
>> + size = report_size;
>> + }
>> +
>> + return size;
>> +}
>> +
>> static int wacom_probe(struct hid_device *hdev,
>> const struct hid_device_id *id)
>> {
>> struct usb_interface *intf = to_usb_interface(hdev->dev.parent);
>> struct usb_device *dev = interface_to_usbdev(intf);
>> - struct usb_endpoint_descriptor *endpoint;
>> struct wacom *wacom;
>> struct wacom_wac *wacom_wac;
>> struct wacom_features *features;
>> @@ -1258,6 +1254,7 @@ static int wacom_probe(struct hid_device *hdev,
>> wacom_wac = &wacom->wacom_wac;
>> wacom_wac->features = *((struct wacom_features *)id->driver_data);
>> features = &wacom_wac->features;
>> + features->pktlen = wacom_compute_pktlen(hdev);
>> if (features->pktlen > WACOM_PKGLEN_MAX) {
>> error = -EINVAL;
>> goto fail1;
>> @@ -1275,8 +1272,6 @@ static int wacom_probe(struct hid_device *hdev,
>> usb_make_path(dev, wacom->phys, sizeof(wacom->phys));
>> strlcat(wacom->phys, "/input0", sizeof(wacom->phys));
>>
>> - endpoint = &intf->cur_altsetting->endpoint[0].desc;
>> -
>> /* set the default size in case we do not get them from hid */
>> wacom_set_default_phy(features);
>>
>> @@ -1287,13 +1282,12 @@ static int wacom_probe(struct hid_device *hdev,
>>
>> /*
>> * Intuos5 has no useful data about its touch interface in its
>> - * HID descriptor. If this is the touch interface (wMaxPacketSize
>> + * HID descriptor. If this is the touch interface (PacketSize
>> * of WACOM_PKGLEN_BBTOUCH3), override the table values.
>> */
>> if (features->type >= INTUOS5S && features->type <= INTUOSHT) {
>> - if (endpoint->wMaxPacketSize == WACOM_PKGLEN_BBTOUCH3) {
>> + if (features->pktlen == WACOM_PKGLEN_BBTOUCH3) {
>> features->device_type = BTN_TOOL_FINGER;
>> - features->pktlen = WACOM_PKGLEN_BBTOUCH3;
>>
>> features->x_max = 4096;
>> features->y_max = 4096;
>> --
>> 2.0.0
>>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2014-07-11 13:28:48

by Benjamin Tissoires

[permalink] [raw]
Subject: Re: [Linuxwacom-devel] [PATCH 00/15] Input - Wacom: switch from an USB to a HID driver

Hi Przemo,

On Thu, Jul 10, 2014 at 5:30 PM, Przemo Firszt <[email protected]> wrote:
> Hi Benjamin,
> I'm having some problems to cleanly apply your patches - can you double
> check that they are OK?

These patches relies on a previous patchset I sent earlier. So they do
not apply cleanly on top of Dmitry's tree as long as the previous
patch set has not been merged :(

As I mentioned in the last series I sent, I pushed a git tree with the
various series applied:
https://github.com/bentiss/linux/commits/hid-wacom-legacy-3.16-rc4

First series is the split of the pad input + various cleanups:
719eaed64c...003c44a74840

Then this series:
71d0261b7b...9be3b169b23

And the last series I sent yesterday:
4fabeed121...f01c5684e6

This is not an ideal solution, but I hope we will figure out soon
enough the way we can merge this upstream (through the HID tree or the
Input tree).

Anyway, I am planing of re-sending the whole various patch series soon
so the maintainer can pick them directly instead of having to dig in
the linux-input archives.

Cheers,
Benjamin

> --
> Regards,
> Przemo
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-input" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html

2014-07-11 13:30:46

by Benjamin Tissoires

[permalink] [raw]
Subject: Re: [PATCH 00/15] Input - Wacom: switch from an USB to a HID driver

Hi Jason,

On Thu, Jul 10, 2014 at 9:17 PM, Jason Gerecke <[email protected]> wrote:
> On Wed, Jul 2, 2014 at 4:33 PM, Jason Gerecke <[email protected]> wrote:
>> On Mon, Jun 30, 2014 at 2:26 PM, Benjamin Tissoires
>> <[email protected]> wrote:
>>> Hi guys,
>>>
>>> this patch series is a cleanup for the Wacom USB driver.
>>>
>>> I started working on this topic when I saw patches floating around which
>>> implemented a report descriptor parser within the wacom.ko module.
>>> However, we already have a nice HID subsystem which is more generic than the
>>> HID implementation we can find in this USB driver.
>>> Further details of the benefits (code reduction, regression tests) are hopefully
>>> explained in the commit messages of the corresponding patches.
>>>
>>> Also, I am working on a way to handle the new Wacom tablets in a more generic
>>> way in the hid tree, so consider this patch series as a first step in this
>>> direction.
>>>
>>> This patch series transfers the wacom.ko driver from the input tree into the hid
>>> tree. I did not made the corresponding move of the files in the series hoping
>>> that we will find a way to achieve it if this step is validated.
>>>
>>> IMO, the smoothest path would be that Jiri takes care of the wacom driver
>>> in the input tree (and that we move into into the hid subfolder). This can be
>>> achieve if the current pending wacom patches are applied in the hid tree too.
>>>
>>> Another solution could be to keep the wacom changes in the input tree and put the
>>> hid changes in the hid tree by using separate commits. Once 3.17 is out, we can
>>> then change the module into the hid subfolder.
>>>
>>> I wanted to send this patch series right now so we can figure out how we will
>>> handle the transition.
>>>
>>> I am pretty confident the patch series does not break any existing device
>>> (except for the required user space changes which can be handled correctly if
>>> we tackle them right now). The USB commands are executed in the same way,
>>> and the protocol handling is also done in the same way.
>>>
>>> Anyway, the net difference in lines of code (-307) should be enough to be of
>>> interest.
>>>
>>> Note: This patch series requires the current pending wacom patches to be applied.
>>> I set up a tree with all the patch applied if anyone wants to give a try:
>>> https://github.com/bentiss/linux/commits/hid-wacom-legacy-3.16-rc3
>>>
>>> Cheers,
>>> Benjamin
>>>
>>> Benjamin Tissoires (15):
>>> Input - wacom: include and use linux/hid.h
>>> Input - wacom: switch from an USB driver to a HID driver
>>> Input - wacom: use hid communication instead of plain usb
>>> Input - wacom: use HID core to actually fetch the report descriptor
>>> Input - wacom: compute the HID report size to get the actual packet
>>> size
>>> Input - wacom: install LED/OLED sysfs files in the HID device instead
>>> of USB
>>> Input - wacom: register the input devices on top of the HID one
>>> Input - wacom: remove usb dependency for siblings devices
>>> Input - wacom: register power device at the HID level
>>> Input - wacom: use hid_info instead of plain dev_info
>>> HID: uhid: add and set HID_TYPE_UHID for uhid devices
>>> Input - wacom: use in-kernel HID parser
>>> Input - wacom: use hidinput_calc_abs_res instead of duplicating its
>>> code
>>> Input - wacom: remove field pktlen declaration in the list of devices
>>> Input - wacom: keep wacom_ids ordered
>>>
>>> drivers/hid/hid-core.c | 15 +-
>>> drivers/hid/hid-wacom.c | 2 +-
>>> drivers/hid/uhid.c | 2 +
>>> drivers/input/tablet/wacom.h | 7 +-
>>> drivers/input/tablet/wacom_sys.c | 908 +++++++++++++--------------------------
>>> drivers/input/tablet/wacom_wac.c | 647 ++++++++++++++--------------
>>> drivers/input/tablet/wacom_wac.h | 10 +-
>>> include/linux/hid.h | 4 +-
>>> 8 files changed, 644 insertions(+), 951 deletions(-)
>>>
>>> --
>>> 2.0.0
>>>
>>
>> *cracks knuckles*
>>
>> Well, guess I better get to work poking and prodding at these and the
>> pad patches. A very quick review doesn't raise any significant flags,
>> though I do have a question or two that I might have for you in the
>> next few days (need to read through the code more carefully to be sure
>> I understand it correctly). My 24HDT is having some trouble
>> initializing with the patches applied, but I'll need some time to
>> track down the cause. Not sure how much I'll get done this week
>> (holiday weekend) but next week I should have some feedback.
>>
>> Jason
>> ---
>> Now instead of four in the eights place /
>> you’ve got three, ‘Cause you added one /
>> (That is to say, eight) to the two, /
>> But you can’t take seven from three, /
>> So you look at the sixty-fours....
>
> I've had a chance to try out a dozen tablets with these modifications
> and for the most part things seem to work fine. The 24HDT issue I
> mentioned above was due to a conflict with some other patches I was
> testing and can be ignored. Aside from the other known issues you've
> already mentioned (and my inline comments), there's not much that I
> can say (other than that I found some odd [but apparently unrelated]
> issues with wacom_w8001 and isdv4-serial-inputattach...)
>
> Reviewed-by: Jason Gerecke <[email protected]>
> Tested-by: Jason Gerecke <[email protected]>
>

Thanks Jason. That's really appreciated. As said I will resend a full
cleanup of these with your Rev-by and fixes, so Dmitry or Jiri can
take the various series.

Cheers,
Benjamin

2014-07-11 13:47:30

by Jiri Kosina

[permalink] [raw]
Subject: Re: [PATCH 00/15] Input - Wacom: switch from an USB to a HID driver

On Fri, 11 Jul 2014, Benjamin Tissoires wrote:

> Thanks Jason. That's really appreciated. As said I will resend a full
> cleanup of these with your Rev-by and fixes, so Dmitry or Jiri can
> take the various series.

Just for the record, I will be mostly offline for the upcoming 2 weeks.

--
Jiri Kosina
SUSE Labs