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

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: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Reviewed-by: default avatarJason Gerecke <killertofu@gmail.com>
Tested-by: default avatarJason Gerecke <killertofu@gmail.com>
Signed-off-by: default avatarDmitry Torokhov <dmitry.torokhov@gmail.com>
parent 27b20a9d
...@@ -15,9 +15,6 @@ ...@@ -15,9 +15,6 @@
#include "wacom.h" #include "wacom.h"
#include <linux/hid.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_UNDEFINED 0x00
#define HID_HDESC_USAGE_PAGE 0x05 #define HID_HDESC_USAGE_PAGE 0x05
#define HID_HDESC_USAGE 0x09 #define HID_HDESC_USAGE 0x09
...@@ -25,15 +22,6 @@ ...@@ -25,15 +22,6 @@
#define HID_HDESC_COLLECTION_LOGICAL 0x02 #define HID_HDESC_COLLECTION_LOGICAL 0x02
#define HID_HDESC_COLLECTION_END 0xc0 #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_MSG_RETRIES 5
#define WAC_CMD_LED_CONTROL 0x20 #define WAC_CMD_LED_CONTROL 0x20
...@@ -230,39 +218,14 @@ static void wacom_retrieve_report_data(struct hid_device *hdev, ...@@ -230,39 +218,14 @@ static void wacom_retrieve_report_data(struct hid_device *hdev,
* this after returning from this function. * this after returning from this function.
*/ */
static int wacom_parse_hid(struct hid_device *hdev, static int wacom_parse_hid(struct hid_device *hdev,
struct wac_hid_descriptor *hid_desc,
struct wacom_features *features) 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 */ /* result has to be defined as int for some devices */
int result = 0, touch_max = 0; int result = 0, touch_max = 0;
int i = 0, page = 0, finger = 0, pen = 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]) { switch (report[i]) {
case HID_HDESC_USAGE_PAGE: case HID_HDESC_USAGE_PAGE:
...@@ -452,11 +415,9 @@ static int wacom_parse_hid(struct hid_device *hdev, ...@@ -452,11 +415,9 @@ static int wacom_parse_hid(struct hid_device *hdev,
} }
} }
out:
if (!features->touch_max && touch_max) if (!features->touch_max && touch_max)
features->touch_max = touch_max; features->touch_max = touch_max;
result = 0; result = 0;
kfree(report);
return result; return result;
} }
...@@ -519,8 +480,6 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev, ...@@ -519,8 +480,6 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
int error = 0; int error = 0;
struct wacom *wacom = hid_get_drvdata(hdev); struct wacom *wacom = hid_get_drvdata(hdev);
struct usb_interface *intf = wacom->intf; struct usb_interface *intf = wacom->intf;
struct usb_host_interface *interface = intf->cur_altsetting;
struct wac_hid_descriptor *hid_desc;
/* default features */ /* default features */
features->device_type = BTN_TOOL_PEN; features->device_type = BTN_TOOL_PEN;
...@@ -549,17 +508,7 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev, ...@@ -549,17 +508,7 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
goto out; goto out;
} }
error = usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc); error = wacom_parse_hid(hdev, features);
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);
out: out:
return error; return error;
...@@ -1296,6 +1245,13 @@ static int wacom_probe(struct hid_device *hdev, ...@@ -1296,6 +1245,13 @@ static int wacom_probe(struct hid_device *hdev,
hid_set_drvdata(hdev, wacom); hid_set_drvdata(hdev, wacom);
wacom->hdev = hdev; 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 = &wacom->wacom_wac;
wacom_wac->features = *((struct wacom_features *)id->driver_data); wacom_wac->features = *((struct wacom_features *)id->driver_data);
features = &wacom_wac->features; features = &wacom_wac->features;
...@@ -1389,12 +1345,6 @@ static int wacom_probe(struct hid_device *hdev, ...@@ -1389,12 +1345,6 @@ static int wacom_probe(struct hid_device *hdev,
wacom_query_tablet_data(hdev, features); wacom_query_tablet_data(hdev, features);
/* Regular HID work starts now */ /* 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); error = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
if (error) { if (error) {
hid_err(hdev, "hw start failed\n"); hid_err(hdev, "hw start failed\n");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment