aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorBenjamin Tissoires <benjamin.tissoires@redhat.com>2014-07-24 15:58:45 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2014-07-25 21:53:51 -0400
commitba9a3541fba72e1532c8288a0775a211810280c1 (patch)
tree7866070d97c08085ce025aaa77c2eabfc537c688 /drivers/input
parent27b20a9dec0cb1a4cc0517b94302875800191e34 (diff)
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 <benjamin.tissoires@redhat.com> Reviewed-by: Jason Gerecke <killertofu@gmail.com> Tested-by: Jason Gerecke <killertofu@gmail.com> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/tablet/wacom_sys.c70
1 files changed, 10 insertions, 60 deletions
diff --git a/drivers/input/tablet/wacom_sys.c b/drivers/input/tablet/wacom_sys.c
index 120ab1b5df3c..2c0983bd0504 100644
--- a/drivers/input/tablet/wacom_sys.c
+++ b/drivers/input/tablet/wacom_sys.c
@@ -15,9 +15,6 @@
15#include "wacom.h" 15#include "wacom.h"
16#include <linux/hid.h> 16#include <linux/hid.h>
17 17
18/* defines to get HID report descriptor */
19#define HID_DEVICET_HID (USB_TYPE_CLASS | 0x01)
20#define HID_DEVICET_REPORT (USB_TYPE_CLASS | 0x02)
21#define HID_HDESC_USAGE_UNDEFINED 0x00 18#define HID_HDESC_USAGE_UNDEFINED 0x00
22#define HID_HDESC_USAGE_PAGE 0x05 19#define HID_HDESC_USAGE_PAGE 0x05
23#define HID_HDESC_USAGE 0x09 20#define HID_HDESC_USAGE 0x09
@@ -25,15 +22,6 @@
25#define HID_HDESC_COLLECTION_LOGICAL 0x02 22#define HID_HDESC_COLLECTION_LOGICAL 0x02
26#define HID_HDESC_COLLECTION_END 0xc0 23#define HID_HDESC_COLLECTION_END 0xc0
27 24
28struct wac_hid_descriptor {
29 struct usb_descriptor_header header;
30 __le16 bcdHID;
31 u8 bCountryCode;
32 u8 bNumDescriptors;
33 u8 bDescriptorType;
34 __le16 wDescriptorLength;
35} __attribute__ ((packed));
36
37#define WAC_MSG_RETRIES 5 25#define WAC_MSG_RETRIES 5
38 26
39#define WAC_CMD_LED_CONTROL 0x20 27#define WAC_CMD_LED_CONTROL 0x20
@@ -230,39 +218,14 @@ static void wacom_retrieve_report_data(struct hid_device *hdev,
230 * this after returning from this function. 218 * this after returning from this function.
231 */ 219 */
232static int wacom_parse_hid(struct hid_device *hdev, 220static int wacom_parse_hid(struct hid_device *hdev,
233 struct wac_hid_descriptor *hid_desc,
234 struct wacom_features *features) 221 struct wacom_features *features)
235{ 222{
236 struct wacom *wacom = hid_get_drvdata(hdev);
237 struct usb_interface *intf = wacom->intf;
238 struct usb_device *dev = interface_to_usbdev(intf);
239 char limit = 0;
240 /* result has to be defined as int for some devices */ 223 /* result has to be defined as int for some devices */
241 int result = 0, touch_max = 0; 224 int result = 0, touch_max = 0;
242 int i = 0, page = 0, finger = 0, pen = 0; 225 int i = 0, page = 0, finger = 0, pen = 0;
243 unsigned char *report; 226 unsigned char *report = hdev->rdesc;
244 227
245 report = kzalloc(hid_desc->wDescriptorLength, GFP_KERNEL); 228 for (i = 0; i < hdev->rsize; i++) {
246 if (!report)
247 return -ENOMEM;
248
249 /* retrive report descriptors */
250 do {
251 result = usb_control_msg(dev, usb_rcvctrlpipe(dev, 0),
252 USB_REQ_GET_DESCRIPTOR,
253 USB_RECIP_INTERFACE | USB_DIR_IN,
254 HID_DEVICET_REPORT << 8,
255 intf->altsetting[0].desc.bInterfaceNumber, /* interface */
256 report,
257 hid_desc->wDescriptorLength,
258 5000); /* 5 secs */
259 } while (result < 0 && limit++ < WAC_MSG_RETRIES);
260
261 /* No need to parse the Descriptor. It isn't an error though */
262 if (result < 0)
263 goto out;
264
265 for (i = 0; i < hid_desc->wDescriptorLength; i++) {
266 229
267 switch (report[i]) { 230 switch (report[i]) {
268 case HID_HDESC_USAGE_PAGE: 231 case HID_HDESC_USAGE_PAGE:
@@ -452,11 +415,9 @@ static int wacom_parse_hid(struct hid_device *hdev,
452 } 415 }
453 } 416 }
454 417
455 out:
456 if (!features->touch_max && touch_max) 418 if (!features->touch_max && touch_max)
457 features->touch_max = touch_max; 419 features->touch_max = touch_max;
458 result = 0; 420 result = 0;
459 kfree(report);
460 return result; 421 return result;
461} 422}
462 423
@@ -519,8 +480,6 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
519 int error = 0; 480 int error = 0;
520 struct wacom *wacom = hid_get_drvdata(hdev); 481 struct wacom *wacom = hid_get_drvdata(hdev);
521 struct usb_interface *intf = wacom->intf; 482 struct usb_interface *intf = wacom->intf;
522 struct usb_host_interface *interface = intf->cur_altsetting;
523 struct wac_hid_descriptor *hid_desc;
524 483
525 /* default features */ 484 /* default features */
526 features->device_type = BTN_TOOL_PEN; 485 features->device_type = BTN_TOOL_PEN;
@@ -549,17 +508,7 @@ static int wacom_retrieve_hid_descriptor(struct hid_device *hdev,
549 goto out; 508 goto out;
550 } 509 }
551 510
552 error = usb_get_extra_descriptor(interface, HID_DEVICET_HID, &hid_desc); 511 error = wacom_parse_hid(hdev, features);
553 if (error) {
554 error = usb_get_extra_descriptor(&interface->endpoint[0],
555 HID_DEVICET_REPORT, &hid_desc);
556 if (error) {
557 hid_err(hdev,
558 "can not retrieve extra class descriptor\n");
559 goto out;
560 }
561 }
562 error = wacom_parse_hid(hdev, hid_desc, features);
563 512
564 out: 513 out:
565 return error; 514 return error;
@@ -1296,6 +1245,13 @@ static int wacom_probe(struct hid_device *hdev,
1296 hid_set_drvdata(hdev, wacom); 1245 hid_set_drvdata(hdev, wacom);
1297 wacom->hdev = hdev; 1246 wacom->hdev = hdev;
1298 1247
1248 /* ask for the report descriptor to be loaded by HID */
1249 error = hid_parse(hdev);
1250 if (error) {
1251 hid_err(hdev, "parse failed\n");
1252 goto fail1;
1253 }
1254
1299 wacom_wac = &wacom->wacom_wac; 1255 wacom_wac = &wacom->wacom_wac;
1300 wacom_wac->features = *((struct wacom_features *)id->driver_data); 1256 wacom_wac->features = *((struct wacom_features *)id->driver_data);
1301 features = &wacom_wac->features; 1257 features = &wacom_wac->features;
@@ -1389,12 +1345,6 @@ static int wacom_probe(struct hid_device *hdev,
1389 wacom_query_tablet_data(hdev, features); 1345 wacom_query_tablet_data(hdev, features);
1390 1346
1391 /* Regular HID work starts now */ 1347 /* Regular HID work starts now */
1392 error = hid_parse(hdev);
1393 if (error) {
1394 hid_err(hdev, "parse failed\n");
1395 goto fail4;
1396 }
1397
1398 error = hid_hw_start(hdev, HID_CONNECT_HIDRAW); 1348 error = hid_hw_start(hdev, HID_CONNECT_HIDRAW);
1399 if (error) { 1349 if (error) {
1400 hid_err(hdev, "hw start failed\n"); 1350 hid_err(hdev, "hw start failed\n");