From: Benjamin Tissoires <benjamin.tissoires@redhat.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
Jiri Kosina <jkosina@suse.cz>, Ping Cheng <pinglinux@gmail.com>,
Jason Gerecke <killertofu@gmail.com>
Cc: linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxwacom-devel@lists.sourceforge.net
Subject: [PATCH 04/15] Input - wacom: use HID core to actually fetch the report descriptor
Date: Mon, 30 Jun 2014 17:26:15 -0400 [thread overview]
Message-ID: <1404163586-29582-5-git-send-email-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <1404163586-29582-1-git-send-email-benjamin.tissoires@redhat.com>
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>
---
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
next prev parent reply other threads:[~2014-06-30 21:26 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-06-30 21:26 [PATCH 00/15] Input - Wacom: switch from an USB to a HID driver Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 01/15] Input - wacom: include and use linux/hid.h Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 02/15] Input - wacom: switch from an USB driver to a HID driver Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 03/15] Input - wacom: use hid communication instead of plain usb Benjamin Tissoires
2014-06-30 21:26 ` Benjamin Tissoires [this message]
2014-06-30 21:26 ` [PATCH 05/15] Input - wacom: compute the HID report size to get the actual packet size Benjamin Tissoires
2014-07-11 1:09 ` Jason Gerecke
2014-07-11 13:20 ` Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 06/15] Input - wacom: install LED/OLED sysfs files in the HID device instead of USB Benjamin Tissoires
2014-07-03 9:21 ` [Linuxwacom-devel] " Przemo Firszt
2014-07-03 13:45 ` Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 07/15] Input - wacom: register the input devices on top of the HID one Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 08/15] Input - wacom: remove usb dependency for siblings devices Benjamin Tissoires
2014-07-11 0:10 ` Jason Gerecke
2014-07-11 13:15 ` Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 09/15] Input - wacom: register power device at the HID level Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 10/15] Input - wacom: use hid_info instead of plain dev_info Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 11/15] HID: uhid: add and set HID_TYPE_UHID for uhid devices Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 12/15] Input - wacom: use in-kernel HID parser Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 13/15] Input - wacom: use hidinput_calc_abs_res instead of duplicating its code Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 14/15] Input - wacom: remove field pktlen declaration in the list of devices Benjamin Tissoires
2014-06-30 21:26 ` [PATCH 15/15] Input - wacom: keep wacom_ids ordered Benjamin Tissoires
2014-07-02 21:40 ` Benjamin Tissoires
2014-07-02 23:33 ` [PATCH 00/15] Input - Wacom: switch from an USB to a HID driver Jason Gerecke
2014-07-11 1:17 ` Jason Gerecke
2014-07-11 13:30 ` Benjamin Tissoires
2014-07-11 13:47 ` Jiri Kosina
2014-07-10 21:30 ` [Linuxwacom-devel] " Przemo Firszt
2014-07-11 13:28 ` Benjamin Tissoires
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1404163586-29582-5-git-send-email-benjamin.tissoires@redhat.com \
--to=benjamin.tissoires@redhat.com \
--cc=dmitry.torokhov@gmail.com \
--cc=jkosina@suse.cz \
--cc=killertofu@gmail.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linuxwacom-devel@lists.sourceforge.net \
--cc=pinglinux@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).