public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Vojtech Pavlik <vojtech@suse.cz>
To: torvalds@osdl.org, vojtech@ucw.cz, linux-kernel@vger.kernel.org
Subject: [PATCH 40/44] Fix for HID devices which need nonzero idle for the ctrl pipe
Date: Tue, 16 Mar 2004 15:19:38 +0100	[thread overview]
Message-ID: <10794467782137@twilight.ucw.cz> (raw)
In-Reply-To: <10794467783749@twilight.ucw.cz>

You can pull this changeset from:
	bk://kernel.bkbits.net/vojtech/input

===================================================================

ChangeSet@1.1608.78.14, 2004-03-10 09:05:31+01:00, davidm@hpl.hp.com
  input: When reading input reports from a device via the ctrl pipe,
         set idle time of the device. This makes buggy devices which
         take the idle time into account for the ctrl pipe work.


 hid-core.c |   23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

===================================================================

diff -Nru a/drivers/usb/input/hid-core.c b/drivers/usb/input/hid-core.c
--- a/drivers/usb/input/hid-core.c	Tue Mar 16 13:17:37 2004
+++ b/drivers/usb/input/hid-core.c	Tue Mar 16 13:17:37 2004
@@ -1108,7 +1108,9 @@
 	hid->cr->wIndex = cpu_to_le16(hid->ifnum);
 	hid->cr->wLength = cpu_to_le16(len);
 
-	dbg("submitting ctrl urb");
+	dbg("submitting ctrl urb: %s wValue=0x%04x wIndex=0x%04x wLength=%u",
+	    hid->cr->bRequest == HID_REQ_SET_REPORT ? "Set_Report" : "Get_Report",
+	    hid->cr->wValue, hid->cr->wIndex, hid->cr->wLength);
 
 	if (usb_submit_urb(hid->urbctrl, GFP_ATOMIC)) {
 		err("usb_submit_urb(ctrl) failed");
@@ -1286,6 +1288,23 @@
 	struct list_head *list;
 	int err, ret;
 
+	/*
+	 * The Set_Idle request is supposed to affect only the
+	 * "Interrupt In" pipe. Unfortunately, buggy devices such as
+	 * the BTC keyboard (ID 046e:5303) the request also affects
+	 * Get_Report requests on the control pipe.  In the worst
+	 * case, if the device was put on idle for an indefinite
+	 * amount of time (as we do below) and there are no input
+	 * events to report, the Get_Report requests will just hang
+	 * until we get a USB timeout.  To avoid this, we temporarily
+	 * establish a minimal idle time of 1ms.  This shouldn't hurt
+	 * bugfree devices and will cause a worst-case extra delay of
+	 * 1ms for buggy ones.
+	 */
+	usb_control_msg(hid->dev, usb_sndctrlpipe(hid->dev, 0),
+			HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, (1 << 8),
+			hid->ifnum, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT);
+
 	report_enum = hid->report_enum + HID_INPUT_REPORT;
 	list = report_enum->report_list.next;
 	while (list != &report_enum->report_list) {
@@ -1319,7 +1338,7 @@
 	while (list != &report_enum->report_list) {
 		report = (struct hid_report *) list;
 		usb_control_msg(hid->dev, usb_sndctrlpipe(hid->dev, 0),
-			0x0a, USB_TYPE_CLASS | USB_RECIP_INTERFACE, report->id,
+			HID_REQ_SET_IDLE, USB_TYPE_CLASS | USB_RECIP_INTERFACE, report->id,
 			hid->ifnum, NULL, 0, HZ * USB_CTRL_SET_TIMEOUT);
 		list = list->next;
 	}


  reply	other threads:[~2004-03-16 14:27 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <10794467771611@twilight.ucw.cz>
2004-03-16 14:19 ` [PATCH 29/44] HID quirk (badpad) for NEC gamepad Vojtech Pavlik
2004-03-16 14:19   ` [PATCH 30/44] Separate HID quirks for different A4Tech mice Vojtech Pavlik
2004-03-16 14:19     ` [PATCH 31/44] Fix i8042 PS/2 mouse on ARM Vojtech Pavlik
2004-03-16 14:19       ` [PATCH 32/44] Update of Wacom driver from Ping Cheng (from Wacom) Vojtech Pavlik
2004-03-16 14:19         ` [PATCH 33/44] Fix for devices that need padded HID packets Vojtech Pavlik
2004-03-16 14:19           ` [PATCH 34/44] Fix a memory leak in ns558.c Vojtech Pavlik
2004-03-16 14:19             ` [PATCH 35/44] HID quirk (badpad) for Chic gamepad Vojtech Pavlik
2004-03-16 14:19               ` [PATCH 36/44] Don't define DEBUG in hid-ff by default Vojtech Pavlik
2004-03-16 14:19                 ` [PATCH 37/44] Restore LED state in atkbd.c after resume Vojtech Pavlik
2004-03-16 14:19                   ` [PATCH 38/44] Fix oops (NULL pointer dereference) on resume in psmouse.c Vojtech Pavlik
2004-03-16 14:19                     ` [PATCH 39/44] Fix an endless loop in hid-core.c if device has empty reports Vojtech Pavlik
2004-03-16 14:19                       ` Vojtech Pavlik [this message]
2004-03-16 14:19                         ` [PATCH 41/44] Don't ignore PS/2 data immediately after disconnect Vojtech Pavlik
2004-03-16 14:19                           ` [PATCH 42/44] Do a full reset of Synaptics touchpad if extended protocol probes failed Vojtech Pavlik
2004-03-16 14:19                             ` [PATCH 43/44] Enable relative mode and gestures if Synaptics uses non-native protocol Vojtech Pavlik
2004-03-16 14:19                               ` [PATCH 44/44] Fixes in wacom.c: SLAB_ATOMIC->GFP_KERNEL and count bug in open() Vojtech Pavlik

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=10794467782137@twilight.ucw.cz \
    --to=vojtech@suse.cz \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=vojtech@ucw.cz \
    /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