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 05/15] Input - wacom: compute the HID report size to get the actual packet size
Date: Mon, 30 Jun 2014 17:26:16 -0400 [thread overview]
Message-ID: <1404163586-29582-6-git-send-email-benjamin.tissoires@redhat.com> (raw)
In-Reply-To: <1404163586-29582-1-git-send-email-benjamin.tissoires@redhat.com>
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 <benjamin.tissoires@redhat.com>
---
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
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 ` [PATCH 04/15] Input - wacom: use HID core to actually fetch the report descriptor Benjamin Tissoires
2014-06-30 21:26 ` Benjamin Tissoires [this message]
2014-07-11 1:09 ` [PATCH 05/15] Input - wacom: compute the HID report size to get the actual packet size 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-6-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).